public override void Update(Address address) { if (_repositoryAddress.Get(address.Id) == null) { throw new ApplicationException("Address not found."); } _repositoryAddress.Update(address); }
public Task Handle(UpdateAdressCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.CompletedTask); } var adress = new Address(message.AddressId, message.Street, message.Number, message.Cep, message.Complement, message.City, message.State, message.Neighborhood); _adressRepository.Update(adress); if (Commit()) { Bus.RaiseEvent(new AdressUpdatedEvent(message.AddressId, adress.Street, adress.Number, adress.Cep, adress.Complement, adress.City, adress.State)); } return(Task.CompletedTask); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <Empty> Update(AddressPut request, ServerCallContext context) { var address = new domain.Entities.Address { Id = request.Id, ZipCode = request.ZipCode, PublicArea = request.PublicArea, Neighborhood = request.Neighborhood, City = request.City, State = request.State, }; if (_repositoryAddress.Get(address.Id) == null) { throw new ApplicationException("Address not found."); } _repositoryAddress.Update(address); return(Task.FromResult(new Empty())); }