public async Task <ActionResult <IEnumerable <Spot> > > GetSpots() { var user = await _userService.GetUserAsync(User); if (await _userService.IsInRoleAsync(user, RoleName.Manager)) { return(Ok(await _spotService.GetAll())); } else if (await _userService.IsInRoleAsync(user, RoleName.MarinaOwner)) { return(Ok(await _spotService.GetAll(_userService.GetMarinaOwnerFromPerson(user).MarinaOwnerId))); } return(StatusCode(403)); }
public async Task <IActionResult> Index() { try { var person = await _userService.GetUserAsync(User); var marinaOwnerId = _userService.GetMarinaOwnerFromPerson(person).MarinaOwnerId; var spots = await _spotService.GetAll(marinaOwnerId); return(View(spots)); } catch (BusinessException e) { Console.WriteLine(e); throw; } }