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

            if (User.IsInRole("Admin") || matchingNurs != null)
            {
                var results = Mapper.Map <IEnumerable <ChildViewModel> >(_repository.GetAllChildren(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" }));
        }