public List<CustomerAgricultureDTO> GetCustomerCustomerAgriCulturesByPageCount(int? pageNumber, int? count) { List<CustomerAgricultureDTO> customerAgricultureList = new List<CustomerAgricultureDTO>(); var customerAgricultures = unitOfWork.CustomerAgricultureRepository.GetCustomerByCount(pageNumber, count); if (customerAgricultures != null) { foreach (var customerAgriculture in customerAgricultures) { customerAgricultureList.Add(CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture)); } } return customerAgricultureList; }
public List<CustomerAgricultureDTO> GetAllCustomerAgriCultures() { List<CustomerAgricultureDTO> customerAgricultureList = new List<CustomerAgricultureDTO>(); var customerAgricultures = unitOfWork.CustomerAgricultureRepository.GetAll(); if (customerAgricultures != null) { foreach (var customerAgriculture in customerAgricultures) { customerAgricultureList.Add(CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture)); } } return customerAgricultureList; }
public ResponseDTO DeleteCustomerAgriculture(int id) { ResponseDTO responseDTO = new ResponseDTO(); UnitOfWork unitOfWork = new UnitOfWork(); //get customerAgriculture var customerAgriculture = unitOfWork.CustomerAgricultureRepository.GetByCustomerId(id); customerAgriculture.IsDeleted = true; unitOfWork.CustomerAgricultureRepository.Update(customerAgriculture); unitOfWork.SaveChanges(); CustomerAgricultureDTO customerAgricultureDTO = CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture); responseDTO.Status = true; responseDTO.Message = "Customer Agriculture Detail Deleted Successfully"; responseDTO.Data = customerAgricultureDTO; return responseDTO; }
public ResponseDTO UpdateCustomerAgriculture(CustomerAgricultureDTO customerAgricultureDTO) { ResponseDTO responseDTO = new ResponseDTO(); var customerAgriculture = unitOfWork.CustomerAgricultureRepository.GetByCustomerId(customerAgricultureDTO.CustomerId); if (customerAgriculture == null) return AddCustomerAgriculture(customerAgricultureDTO); CustomerAgricultureConvertor.ConvertToCustomerAgriCultureEntity(ref customerAgriculture, customerAgricultureDTO, true); // customerAgriculture.ModifiedBy = unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customerAgriculture.Customer.VLCId.GetValueOrDefault()); customerAgriculture.ModifiedDate = DateTimeHelper.GetISTDateTime(); unitOfWork.CustomerAgricultureRepository.Update(customerAgriculture); unitOfWork.SaveChanges(); customerAgricultureDTO = CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture); responseDTO.Status = true; responseDTO.Message = "Customer Agriculture Detail Updated Successfully"; responseDTO.Data = customerAgricultureDTO; return responseDTO; }
public ResponseDTO GetCustomerAgriCultureById(int customerId) { ResponseDTO responseDTO = new ResponseDTO(); CustomerAgricultureDTO customerAgricultureDTO = null; var customerAgriculture = unitOfWork.CustomerAgricultureRepository.GetByCustomerId(customerId); if (customerAgriculture != null) { customerAgricultureDTO = CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture); responseDTO.Status = true; responseDTO.Message = "Customer Agriculture Details Found"; responseDTO.Data = customerAgricultureDTO; } else { responseDTO.Status = false; responseDTO.Message = String.Format("Customer Agriculture Details Not Found For Customer Id {0}", customerId); responseDTO.Data = new object(); } return responseDTO; }
public ResponseDTO GetCustomerDetailsByCustomerId(int customerId) { ResponseDTO responseDTO = new ResponseDTO(); CustomerDetailsDTO customerDetailsDto = new CustomerDetailsDTO(); var customer = unitOfWork.CustomerRepository.GetById(customerId); if (customer != null) { customerDetailsDto.customerProfileDetails = CustomerConvertor.ConvertToCustomerDto(customer); if (customer.CustomerBanks != null) { customerDetailsDto.customerBankDetails = CustomerBankConvertor.ConvertTocustomerBankDto(customer.CustomerBanks.FirstOrDefault()); } else { customerDetailsDto.customerBankDetails = new CustomerBankDTO(); } if (customer.CustomerAgricultures != null) { customerDetailsDto.customerAgricultureDetails = CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customer.CustomerAgricultures.FirstOrDefault()); } else { customerDetailsDto.customerAgricultureDetails = new CustomerAgricultureDTO(); } responseDTO.Status = true; responseDTO.Message = "Customer Profile Details"; responseDTO.Data = customerDetailsDto; } else { throw new PlatformModuleException("Customer Details Not Found with given Customer Id"); } return(responseDTO); }
public ResponseDTO AddCustomerAgriculture(CustomerAgricultureDTO customerAgricultureDTO) { ResponseDTO responseDTO = new ResponseDTO(); this.CheckForExisitngCustomerAgriculture(customerAgricultureDTO.CustomerId); CustomerAgriculture customerAgriculture = new CustomerAgriculture(); customerAgriculture.CustAgriId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerAgriculture"); customerAgriculture.CreatedDate = DateTimeHelper.GetISTDateTime(); customerAgriculture.IsDeleted = false; customerAgriculture.ModifiedBy = customerAgriculture.CreatedBy = unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customerAgricultureDTO.VLCId); customerAgriculture.ModifiedDate = DateTimeHelper.GetISTDateTime(); CustomerAgricultureConvertor.ConvertToCustomerAgriCultureEntity(ref customerAgriculture, customerAgricultureDTO, false); unitOfWork.CustomerAgricultureRepository.Add(customerAgriculture); unitOfWork.SaveChanges(); customerAgricultureDTO= CustomerAgricultureConvertor.ConvertToCustomerAgriCultureDto(customerAgriculture); responseDTO.Status = true; responseDTO.Message = "Customer Agriculture Detail Added Successfully"; responseDTO.Data = customerAgricultureDTO; return responseDTO; }