예제 #1
0
        public JsonResult GetEmpoyees(int nurseryId)
        {
            var matchingNurs = User.FindAll("Nursery").FirstOrDefault(claim => claim.Value == nurseryId.ToString());

            if (User.IsInRole("Admin") || matchingNurs != null)
            {
                var results = Mapper.Map <IEnumerable <EmployeeViewModel> >(_repository.GetAllEmployees(nurseryId));
                return(Json(results));
            }

            _logger.LogInformation("Attempting to get unauthorized nursery");
            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Json(new { Message = "Do not have permissionts to view this item" }));
        }