Ejemplo n.º 1
0
        public JsonResult GetClasses(int nurseryId)
        {
            var matchingNurs = User.FindAll("Nursery").FirstOrDefault(claim => claim.Value == nurseryId.ToString());

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