Esempio n. 1
0
        public void UpdateCustomer(CustomerDto customerDto)
        {
            var customer = unitOfWork.CustomerRepository.GetById(customerDto.CustomerId);

            CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, true);

            unitOfWork.CustomerRepository.Update(customer);
            unitOfWork.SaveChanges();
        }
Esempio n. 2
0
        public CustomerDto GetCustomerById(int customerId)
        {
            CustomerDto customerDto = null;
            var         customer    = unitOfWork.CustomerRepository.GetById(customerId);

            if (customer != null)
            {
                customerDto = CustomerConvertor.ConvertToCustomerDto(customer);
            }
            return(customerDto);
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        public List <CustomerDto> GetCustomerByPageCount(int?pageNumber, int?count)
        {
            List <CustomerDto> customerList = new List <CustomerDto>();
            var customers = unitOfWork.CustomerRepository.GetCustomerByCount(pageNumber, count);

            if (customers != null)
            {
                foreach (var customer in customers)
                {
                    customerList.Add(CustomerConvertor.ConvertToCustomerDto(customer));
                }
            }

            return(customerList);
        }
Esempio n. 5
0
        public List <CustomerDto> GetAllCustomers()
        {
            List <CustomerDto> customerList = new List <CustomerDto>();
            var customers = unitOfWork.CustomerRepository.GetAll();

            if (customers != null)
            {
                foreach (var customer in customers)
                {
                    customerList.Add(CustomerConvertor.ConvertToCustomerDto(customer));
                }
            }

            return(customerList);
        }
Esempio n. 6
0
        public List <CustomerDto> GetCustomerDetailsByVLCCode(string vlcCode)
        {
            List <CustomerDto> customerList = new List <CustomerDto>();
            var customers = unitOfWork.CustomerRepository.GetAll().Where(id => id.VLC.VLCCode == vlcCode).ToList();

            if (customers != null)
            {
                foreach (var customer in customers)
                {
                    customerList.Add(CustomerConvertor.ConvertToCustomerDto(customer));
                }
            }

            return(customerList);
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        public ResponseDTO GetCustomerListForSearchByVLCId(int vlcId)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            List <CustomerSearchDTO> customerList = new List <CustomerSearchDTO>();
            var customers = unitOfWork.CustomerRepository.GetCustomerListForSearchByVLCId(vlcId);

            if (customers != null)
            {
                foreach (var customer in customers)
                {
                    customerList.Add(CustomerConvertor.ConvertToCustomerSearchDto(customer));
                }
            }
            responseDTO.Status  = true;
            responseDTO.Message = String.Format("List of Customers By VLC Id");
            responseDTO.Data    = customerList;
            return(responseDTO);
        }
Esempio n. 9
0
        public ResponseDTO DeleteCustomer(int id)
        {
            UnitOfWork unitOfWork = new UnitOfWork();
            //get customer
            var customer = unitOfWork.CustomerRepository.GetById(id);

            //if((customer.ProductOrders !=null && customer.ProductOrders.Count()>0) || (customer.CustomerWallets !=null &&
            //    customer.CustomerWallets.Count()>0 && customer.CustomerWallets.FirstOrDefault().WalletBalance>0))
            //    {
            //    throw new PlatformModuleException("Customer Account Cannot be deleted as it is associated with orders");
            //}
            unitOfWork.CustomerRepository.Delete(id);
            unitOfWork.SaveChanges();
            ResponseDTO responseDTO = new ResponseDTO();

            responseDTO.Status  = true;
            responseDTO.Message = String.Format("Customer Deleted Successfully");
            responseDTO.Data    = CustomerConvertor.ConvertToCustomerDto(customer);
            return(responseDTO);
        }
Esempio n. 10
0
        public ResponseDTO GetCustomerByCustomerId(int customerId)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            CustomerDto customerDto = null;
            var         customer    = unitOfWork.CustomerRepository.GetById(customerId);

            if (customer != null)
            {
                customerDto         = CustomerConvertor.ConvertToCustomerDto(customer);
                responseDTO.Status  = true;
                responseDTO.Message = "Customer Detail By Customer Id";
                responseDTO.Data    = customerDto;
            }
            else
            {
                responseDTO.Status  = false;
                responseDTO.Message = "No Customer Exist with given customer Id";
                responseDTO.Data    = new object();
            }
            return(responseDTO);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }