public async Task <ActionResult <IEnumerable <Marina> > > GetMarinas()
        {
            var user = await _userService.GetUserAsync(User);

            if (await _userService.IsInRoleAsync(user, RoleName.Manager))
            {
                return(Ok(await _marinaService.GetAll()));
            }
            else if (await _userService.IsInRoleAsync(user, RoleName.MarinaOwner))
            {
                return(Ok(await _marinaService.GetAll(_userService.GetMarinaOwnerFromPerson(user).MarinaOwnerId)));
            }
            return(StatusCode(403));
        }
        private async Task <SelectList> MarinaList()
        {
            var person = await _userService.GetUserAsync(User);

            var marinaOwnerId = _userService.GetMarinaOwnerFromPerson(person).MarinaOwnerId;

            var marinas = await _marinaService.GetAll(marinaOwnerId);

            var marinaList = new SelectList(marinas, "MarinaId", "MarinaId");

            return(marinaList);
        }
        public async Task <IActionResult> Index()
        {
            try
            {
                var person = await _userManager.GetUserAsync(User);

                var marinaOwnerId = _userService.GetMarinaOwnerFromPerson(person).MarinaOwnerId;

                var marinas = await _marinaService.GetAll(marinaOwnerId);

                return(View(marinas));
            }
            catch (BusinessException e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #4
0
        public async Task <IActionResult> CreateMarinaMap(string boat, string start, string end)
        {
            var boatId    = int.Parse(boat);
            var startDate = DateTime.Parse(start);
            var endDate   = DateTime.Parse(end);

            var jsonString = HelperMethods.Serialize(await _bookingService.GetAllAvailableSpotsCount((await _marinaService.GetAll()).Select(m => m.MarinaId).ToList(), boatId, startDate, endDate));

            return(new JsonResult(jsonString));
        }