예제 #1
0
        public async Task <IActionResult> Delete(string id)
        {
            if (id == "bad")
            {
                var problemDetails = new ProblemDetails
                {
                    Status   = StatusCodes.Status400BadRequest,
                    Type     = "https://localhost:5001/Addresses/failed-to-delete",
                    Title    = $"Address ID {id} found but failed to delete.",
                    Detail   = "More details like Company Name, Country and so on.",
                    Instance = HttpContext.Request.Path
                };
                return(BadRequest(problemDetails)); // 400 Bad request
            }

            var existing = await repo.RetrieveAsync(id);

            if (existing == null)
            {
                return(NotFound()); // 404 Resource not found
            }

            bool?deleted = await repo.DeleteAsync(id);

            if (deleted.HasValue && deleted.Value) // short circuit AND
            {
                return(new NoContentResult());     // 204 No content
            }
            else
            {
                return(BadRequest( // 400 Bad request
                           $"Address {id} was found but failed to delete."));
            }
        }
예제 #2
0
        public async Task Should_DeleteAddressAsync()
        {
            _addressRepository.DeleteAsync(Arg.Any <IAddress>())
            .Returns(true);
            var response = await _handler.Handle(GetRequest(), CancellationToken.None);

            Assert.False(response.HasMessages);
        }
        public async Task <AddressDto> DeleteAsync(int userId, int id)
        {
            var model = await _addressRepository.DeleteAsync(userId, id);

            var result = AddressDtoMapper.Map(model);

            return(result);
        }
        public async Task <IHttpActionResult> Delete([FromODataUri] System.Guid key)
        {
            logger.Trace("Call AddressController Delete");

            await AddressRepository.DeleteAsync(key);

            return(Ok());
        }
예제 #5
0
        public async Task <IActionResult> Delete(int id)
        {
            var status = await _addressRepository.DeleteAsync(APISetting.AddressAPIPath, id, HttpContext.Session.GetString("JWToken"));

            if (status)
            {
                return(Json(new { success = true, message = "Delete Successful" }));
            }
            return(Json(new { success = false, message = "Delete Not Successful" }));
        }
예제 #6
0
        public async Task <object> Delete(Guid contactId, Guid id)
        {
            _logger.LogInformation($"delete.address contact: {id} record: {id}");
            AssertValidIds(contactId, id);
            var resp = await _repository.DeleteAsync(contactId, id);

            _logger.LogInformation($"deleted.address contact: {id} record: {id} resp: {resp}");
            return(new
            {
                Message = "Deleted Address"
            });
        }
        public async Task <Response> Handle(RemoveAddressRequest request,
                                            CancellationToken cancellationToken)
        {
            var response = new Response();
            var Address  = _mapper.Map <Address>(request);

            _logger.LogTrace("Remove o endereço do motorista", Address);

            await _addressRepository.DeleteAsync(Address);

            return(response);
        }
예제 #8
0
        public async Task <int> DeleteAddressAsync(int addressId)
        {
            AddressEntity addressEntity = await _addressRep.FirstOrDefaultAsync(m => m.Id == addressId);

            if (addressEntity != null)
            {
                await _addressRep.DeleteAsync(m => m.Id == addressId);

                await _uow.SaveChangesAsync();

                return(addressId);
            }

            return(0);
        }
        public async Task <DeleteResponse> DeleteAsync(int id)
        {
            var deleteResponse = new DeleteResponse();

            try
            {
                deleteResponse = await _addressRepository.DeleteAsync(id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                deleteResponse.AddError(ex);
                _logManager.LogError(ex, "Unable to delete address");
            }

            return(deleteResponse);
        }
        public async Task <IActionResult> Delete(int id)
        {
            Address existing = await addressRepository.FindByIdAsync(id);

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

            bool deleted = await addressRepository.DeleteAsync(existing);

            if (deleted)
            {
                return(new OkResult());
            }

            return(BadRequest());
        }
예제 #11
0
        public async Task DeleteAsync(Guid id)
        {
            if (CurrentUser == null)
            {
                return;
            }

            var customerAddress = (await _customerAddressRepository.ListByCustomerId((Guid)CurrentUser.Id))
                                  .FirstOrDefault(x => x.AddressId == id);

            if (customerAddress == null)
            {
                return;
            }

            await _customerAddressRepository.DeleteAsync(customerAddress);

            await _addressRepository.DeleteAsync(id);
        }
        public async Task <IServiceResult> DeleteAsync(Guid uuid)
        {
            try
            {
                var phones = await _localPhoneRepository.GetGuidsFromAddress(uuid);

                foreach (var phoneUuid in phones)
                {
                    await _localPhoneRepository.DeleteAsync(phoneUuid);
                }
                await _addressRepository.DeleteAsync(uuid);

                return(new SuccessResult());
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error while deleting address");
                return(new FailResult());
            }
        }
예제 #13
0
        public async Task <IActionResult> DeleteAddress(string personId, string addressId)
        {
            await _addressRepository.DeleteAsync(personId, addressId);

            return(Ok());
        }
예제 #14
0
 public async Task <bool> Delete(Guid id)
 {
     return(await _repository.DeleteAsync(id));
 }