public void Update(int id, UpdateShareHolderDto dto) { var shareHolder = _shareHolderRepository.FindById(id); if (shareHolder == null) { throw new Exception("ShareHolder was not found"); } if (dto.FirstName != null) { shareHolder.FirstName = dto.FirstName; } if (dto.LastName != null) { shareHolder.LastName = dto.LastName; } if (dto.Email != null) { shareHolder.Email = dto.Email; } if (dto.Phone != null) { shareHolder.Phone = dto.Phone; } if (dto.ShareHolderTypeId != shareHolder.ShareHolderType.Id) { var shareHolderType = _shareHolderTypeRepository.FindById(dto.ShareHolderTypeId); if (shareHolderType != null) { shareHolder.ShareHolderType = shareHolderType; } } if (dto.AddressId != shareHolder.Address.Id) { var address = _addressRepository.FindById(dto.AddressId); if (address != null) { shareHolder.Address = address; } } _shareHolderRepository.Update(shareHolder); }
public void Put(int id, [FromBody] UpdateShareHolderDto dto) { _shareHolderService.Update(id, dto); }