Skip to content

Instantly share code, notes, and snippets.

@gzamudio
Last active March 14, 2019 18:29
Show Gist options
  • Save gzamudio/4779860b6a8093f2ed50fa03d2a22fca to your computer and use it in GitHub Desktop.
Save gzamudio/4779860b6a8093f2ed50fa03d2a22fca to your computer and use it in GitHub Desktop.
public async Task<IActionResult> CategoryMetric(string startingDate, int? schoolId)
{
var currentUser = (await UserManager.FindByEmailAsync(User.Identity.Name));
try
{
if (GetSchoolToSearch(currentUser, schoolId) == null && !currentUser.IsInRole("Admin"))
return BadRequest(Localizer["UserIsNotSchoolGroupAdmin"]);
return Ok(GetSchoolGroupAccesedResources(schoolId,
currentUser.SchoolGroup, DateTime.ParseExact(startingDate,
"dd/MM/yyyy",
CultureInfo.InvariantCulture)));
}
catch (NullReferenceException)
{
return BadRequest(Localizer["UserDoesNotBelongToASchool"]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment