Пример #1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            try
            {
                var marina = await _marinaService.GetSingle(id);

                var isAuthorized = await _authorizationService.AuthorizeAsync(User, marina, Operation.Delete);

                if (!isAuthorized.Succeeded)
                {
                    Forbid();
                }

                await _marinaService.DeleteMarinaLocation(marina);

                await _marinaService.Delete(id);

                await _marinaService.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch (BusinessException e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Пример #2
0
        public async Task <IActionResult> DeleteSpot(int id)
        {
            var marina = _marinaService.GetSingle(id);

            var isAuthorized = await _authorizationService.AuthorizeAsync(User, await marina, Operation.Delete);

            if (isAuthorized.Succeeded)
            {
                await _marinaService.Delete(id);

                await _marinaService.Save();

                return(NoContent());
            }

            return(StatusCode(403));
        }