public ResponseDTO AddCustomerBank(CustomerBankDTO customerBankDto) { ResponseDTO responseDTO = new ResponseDTO(); CustomerBank customerBank = new CustomerBank(); var exisitingcustomerBank = unitOfWork.CustomerBankRepository.GetByCustomerId(customerBankDto.CustomerId); if (exisitingcustomerBank != null) { throw new PlatformModuleException(string.Format("Customer Bank Account Details Already Exist For Customer Id {0}", customerBankDto.CustomerId)); } customerBank.CustomerBankId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerBank"); CustomerBankConvertor.ConvertToCustomerBankEntity(ref customerBank, customerBankDto, false); customerBank.CreatedBy = "Admin"; customerBank.CreatedDate = DateTimeHelper.GetISTDateTime(); customerBank.IsDeleted = false; customerBank.ModifiedBy = "Admin"; customerBank.ModifiedDate = DateTimeHelper.GetISTDateTime(); unitOfWork.CustomerBankRepository.Add(customerBank); unitOfWork.SaveChanges(); customerBankDto = CustomerBankConvertor.ConvertTocustomerBankDto(customerBank); responseDTO.Status = true; responseDTO.Message = "Customer Bank Added Successfully"; responseDTO.Data = customerBankDto; return(responseDTO); }
public ResponseDTO UpdateCustomerBank(CustomerBankDTO customerBankDto) { ResponseDTO responseDTO = new ResponseDTO(); var customerBank = unitOfWork.CustomerBankRepository.GetByCustomerId(customerBankDto.CustomerId); if (customerBank == null) { return(AddCustomerBank(customerBankDto)); } CustomerBankConvertor.ConvertToCustomerBankEntity(ref customerBank, customerBankDto, true); customerBank.ModifiedDate = DateTimeHelper.GetISTDateTime(); // customerBank.ModifiedBy = unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customerBank.Customer.VLCId.GetValueOrDefault()); unitOfWork.CustomerBankRepository.Update(customerBank); unitOfWork.SaveChanges(); customerBankDto = CustomerBankConvertor.ConvertTocustomerBankDto(customerBank); responseDTO.Status = true; responseDTO.Message = "Customer Bank Updated Successfully"; responseDTO.Data = customerBankDto; return(responseDTO); }