public ResponseDTO UpdateCustomer(CustomerDto customerDto) { ResponseDTO responseDTO = new ResponseDTO(); var customer = unitOfWork.CustomerRepository.GetById(customerDto.CustomerId); if (customer != null) { CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, true); customer.ModifiedDate = DateTimeHelper.GetISTDateTime(); customer.ModifiedBy = unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customer.VLCId.GetValueOrDefault()); unitOfWork.CustomerRepository.Update(customer); unitOfWork.SaveChanges(); responseDTO.Status = true; responseDTO.Message = String.Format("Customer Updated Successfully"); responseDTO.Data = CustomerConvertor.ConvertToCustomerDto(customer); } else { responseDTO.Message = "Customer Account Not Found with Customer Id. Please try to update again."; responseDTO.Status = false; } return(responseDTO); }
public void UpdateCustomer(CustomerDto customerDto) { var customer = unitOfWork.CustomerRepository.GetById(customerDto.CustomerId); CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, true); unitOfWork.CustomerRepository.Update(customer); unitOfWork.SaveChanges(); }
public void AddCustomer(CustomerDto customerDto) { // this.CheckForExisitngCustomer(customerDto.MobileNumber); Customer customer = new Customer(); customer.CustomerId = unitOfWork.DashboardRepository.NextNumberGenerator("Customer"); CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, false); unitOfWork.CustomerRepository.Add(customer); unitOfWork.SaveChanges(); }
public void AddCustomer(CustomerDto customerDto) { // this.CheckForExisitngCustomer(customerDto.MobileNumber); Customer customer = new Customer(); customer.CustomerId = unitOfWork.DashboardRepository.NextNumberGenerator("Customer"); CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, false); unitOfWork.CustomerRepository.Add(customer); //creating customer wallet with customer CustomerWallet customerWallet = new CustomerWallet(); customerWallet.WalletId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerWallet"); customerWallet.CustomerId = customer.CustomerId; customerWallet.WalletBalance = 0; customerWallet.AmountDueDate = DateTime.Now.AddDays(10); unitOfWork.CustomerWalletRepository.Add(customerWallet); unitOfWork.SaveChanges(); }
public ResponseDTO AddCustomer(CustomerDto customerDto) { ResponseDTO responseDTO = new ResponseDTO(); if (!this.CheckForExisitngCustomer(customerDto)) { Customer customer = new Customer(); customer.CustomerId = unitOfWork.DashboardRepository.NextNumberGenerator("Customer"); var vlc = unitOfWork.VLCRepository.GetById(customerDto.VLCId); if (vlc != null) { CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, false); customer.CustomerCode = unitOfWork.CustomerRepository.GetCustomerCodeIdByVLC(customerDto.VLCId); customer.CreatedDate = DateTimeHelper.GetISTDateTime(); customer.ModifiedDate = DateTimeHelper.GetISTDateTime(); customer.CreatedBy = customer.ModifiedBy = vlc.AgentName ?? "System"; customer.DateOfJoinVLC = DateTimeHelper.GetISTDateTime().Date; customer.IsDeleted = false; customer.VLCId = customerDto.VLCId; unitOfWork.CustomerRepository.Add(customer); customerDto = CustomerConvertor.ConvertToCustomerDto(customer); unitOfWork.SaveChanges(); responseDTO.Status = true; responseDTO.Message = String.Format("Customer Successfully Created"); responseDTO.Data = customerDto; } else { throw new PlatformModuleException("VLC Details Not Found"); } } else { responseDTO.Message = "Customer with this Contact & Email already exists.Please enter unique contact & Email."; responseDTO.Status = false; } return(responseDTO); }