コード例 #1
0
        //  [Authorize(Roles = "Admin, Employee")]
        public IActionResult GetAll()
        {
            // Assume the user is not authorized
            IActionResult result = Unauthorized();

            try
            {
                var classes = _db.GetClasses();
                var dtoArr  = classes.Select(x => MapToDTO(x)).ToArray();
                result = Ok(dtoArr);
            }
            catch (Exception)
            {
                result = BadRequest(new { Message = "Get all classes failed." });
            }

            return(result);
        }