public async Task <IActionResult> Edit(int id,
                                               [Bind("MarinaOwnerId, Name, Description, Facilities, LocationId")]
                                               Marina marina)
        {
            marina.MarinaId = id;
            try
            {
                var isAuthorized = await _authorizationService.AuthorizeAsync(User, marina, Operation.Update);

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

                if (!ModelState.IsValid)
                {
                    return(View(marina));
                }

                if (MarinaLocationIsSelected())
                {
                    var marinaLocation = GetLocationFormData();

                    _marinaService.UpdateMarinaLocation(marina, marinaLocation);
                    await _marinaService.CreateLocationForMarina(marina, marinaLocation);
                }
                else
                {
                    marina = await _marinaService.DeleteMarinaLocation(marina);
                }

                _marinaService.Update(marina);
                await _marinaService.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch (BusinessException exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }
        public async Task <IActionResult> PutMarina(int id, Marina marina)
        {
            if (id != marina.MarinaId)
            {
                return(BadRequest());
            }

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

            if (isAuthorized.Succeeded)
            {
                _marinaService.Update(marina);
                try
                {
                    await _marinaService.Save();
                }
                catch (BusinessException ex)
                {
                    BadRequest(ex);
                }
            }

            return(NoContent());
        }