Esempio n. 1
0
        public async Task <IActionResult> GetAirplanes()
        {
            if (!int.TryParse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? string.Empty, out _))
            {
                return(Unauthorized());
            }

            var privilages = new List <int>()
            {
                (int)UserPrivileges.Administrator, (int)UserPrivileges.Employee
            };

            int.TryParse(User.FindFirst(ClaimTypes.Role)?.Value, out var privilagesId);

            if (!privilages.Contains(privilagesId))
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized));
            }

            var result = await _airplaneRepository.GetAirplanes();

            return(result != null?Ok(result) : StatusCode((int)HttpStatusCode.InternalServerError));
        }
Esempio n. 2
0
 public IEnumerable <Airplane> GetAll()
 {
     return(_airplaneRepository.GetAirplanes());
 }