Exemplo n.º 1
0
        public IActionResult GetAll()
        {
            var currUser = _userService.GetById(Int32.Parse(User.Identity.Name));

            var timeZones = _timeZoneService.GetAll();

            // if the current user is not an admin, only return the time zones that he is the owner of
            if (!_userService.CheckIf(currUser, Roles.ROLE_ADMIN))
            {
                timeZones = timeZones.Where(x => x.UserId == currUser.Id);
            }
            var model = _mapper.Map <IList <TimeZoneModel> >(timeZones);

            return(Ok(model));
        }