예제 #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Address == null)
            {
                return(NotFound());
            }

            _logger.LogInformation(LoggingEvents.GetItem, "Get Address {ID}", Address.Id);
            var address = await _addressService.GetAddress(Address.Id);

            if (address == null)
            {
                _logger.LogInformation(LoggingEvents.GetItemNotFound, "Get Address {ID} NOT FOUND", address.Id);
                return(NotFound());
            }

            try
            {
                _logger.LogInformation(LoggingEvents.UpdateItem, "Admin updated Address {ID}", address.Id);
                await _addressService.EditAddress(Address);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_addressService.AddressExists(address.Id))
                {
                    _logger.LogInformation(LoggingEvents.UpdateItemNotFound, "Updated Address {ID} NOT FOUND", address.Id);
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(409));
                }
            }

            return(RedirectToPage("./Index"));
        }