public async Task <IActionResult> GetTours() { IEnumerable <Entities.Tour> toursFromRepo = new List <Entities.Tour>(); if (_userInfoService.Role == "Administrator") { toursFromRepo = await _tourManagementRepository.GetTours(); } else { var userId = Int32.Parse(_userInfoService.UserId); // work around for int if (!(userId > 0)) { return(Forbid()); } toursFromRepo = await _tourManagementRepository.GetToursForManager(userId); } var tours = Mapper.Map <IEnumerable <Tour> >(toursFromRepo); return(Ok(tours)); }
public async Task <IActionResult> GetTours() { IEnumerable <Entities.Tour> toursFromRepo = new List <Entities.Tour>(); if (_userInfoService.Role == "Administrator") { toursFromRepo = await _tourManagementRepository.GetTours(); } else { if (!Guid.TryParse(_userInfoService.UserId, out Guid userIdAsGuid)) { return(Forbid()); } toursFromRepo = await _tourManagementRepository.GetToursForManager(userIdAsGuid); } var tours = Mapper.Map <IEnumerable <Tour> >(toursFromRepo); return(Ok(tours)); }