public IActionResult Get() { try { IEnumerable <Assignment> results = null; ClaimsPrincipal user = HttpContext.User; if (user.Claims.SingleOrDefault(x => x.Type == ClaimTypes.Role)?.Value == "Admin") { results = assignmentManager.GetAll(); } else { int repId = Convert.ToInt32(user.Claims.FirstOrDefault(x => x.Type == "RepId")?.Value); if (periodManager == null) { return(BadRequest(config["Error:Default"])); } Period period = periodManager.Find(x => x.IsOpen).SingleOrDefault(); if (period != null) { results = assignmentManager.Get(null, repId, period.PeriodId); } } return(Ok(results)); } catch (Exception ex) { logger.LogError($"Failed to get all assignments: {ex}"); return(BadRequest(config["Error:Default"])); } }