예제 #1
0
        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);
        }
        //Post api/Customer

        public IHttpActionResult Post([FromBody] CustomerBankDTO customerBank)
        {
            try
            {
                if (customerBank == null)
                {
                    Ok(ResponseHelper.CreateResponseDTOForException("Argument Null"));
                }
                //Create New Customer
                ResponseDTO responseDTO = _customerBankService.AddCustomerBank(customerBank);

                return(Ok(responseDTO));
            }
            catch (PlatformModuleException ex)
            {
                //Write Log Here
                return(Ok(ResponseHelper.CreateResponseDTOForException(ex.Message)));
            }
        }
        public IHttpActionResult Post(int id, [FromBody] CustomerBankDTO customerBankDTO)
        {
            try
            {
                customerBankDTO.CustomerId = id;
                if (customerBankDTO == null)
                {
                    return(Ok(ResponseHelper.CreateResponseDTOForException("Argument Null")));
                }
                //Update New Customer


                return(Ok(_customerBankService.UpdateCustomerBank(customerBankDTO)));
            }
            catch (PlatformModuleException ex)
            {
                //Write Log Here
                return(Ok(ResponseHelper.CreateResponseDTOForException(ex.Message)));
            }
        }
예제 #4
0
        public ResponseDTO GetCustomerBankById(int customerId)
        {
            ResponseDTO     responseDTO     = new ResponseDTO();
            CustomerBankDTO customerBankDto = null;
            var             customerBank    = unitOfWork.CustomerBankRepository.GetByCustomerId(customerId);

            if (customerBank != null)
            {
                customerBankDto     = CustomerBankConvertor.ConvertTocustomerBankDto(customerBank);
                responseDTO.Status  = true;
                responseDTO.Message = "Customer Bank Details For Customer";
                responseDTO.Data    = customerBankDto;
            }
            else
            {
                responseDTO.Status  = false;
                responseDTO.Message = String.Format("Customer Bank Details with Customer ID {0} not found", customerId);
                responseDTO.Data    = new object();
            }
            return(responseDTO);
        }
예제 #5
0
        public ResponseDTO DeleteCustomerBank(int id)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            UnitOfWork  unitOfWork  = new UnitOfWork();
            //get customerBank
            var customerBank = unitOfWork.CustomerBankRepository.GetByCustomerId(id);

            //if((customerBank.ProductOrders !=null && customerBank.ProductOrders.Count()>0) || (customerBank.CustomerWallets !=null &&
            //    customerBank.CustomerWallets.Count()>0 && customerBank.CustomerWallets.FirstOrDefault().WalletBalance>0))
            //    {
            //    throw new PlatformModuleException("CustomerBank Account Cannot be deleted as it is associated with orders");
            //}
            unitOfWork.CustomerBankRepository.Delete(id);
            unitOfWork.SaveChanges();
            CustomerBankDTO customerBankDTO = CustomerBankConvertor.ConvertTocustomerBankDto(customerBank);

            responseDTO.Status  = true;
            responseDTO.Message = "Customer Bank Deleted Successfully";
            responseDTO.Data    = customerBankDTO;
            return(responseDTO);
        }
예제 #6
0
        public static CustomerBankDTO ConvertTocustomerBankDto(CustomerBank customerBank)
        {
            CustomerBankDTO customerBankDto = new CustomerBankDTO();

            if (customerBank != null)
            {
                customerBankDto.CustomerBankId    = customerBank.CustomerBankId;
                customerBankDto.CustomerId        = customerBank.CustomerId.GetValueOrDefault();
                customerBankDto.IFSCCode          = customerBank.IFSCCode;
                customerBankDto.AccountNo         = customerBank.AccountNo;
                customerBankDto.Branch            = customerBank.Branch;
                customerBankDto.BankName          = customerBank.BankName;
                customerBankDto.AccountHolderName = customerBank.AccountHolderName;
                customerBankDto.UPIId             = customerBank.UPIId;
                customerBankDto.CreatedBy         = customerBank.CreatedBy;
                customerBankDto.CreatedDate       = customerBank.CreatedDate;
                customerBankDto.IsDeleted         = customerBank.IsDeleted;
                customerBankDto.ModifiedBy        = customerBank.ModifiedBy;
                customerBankDto.ModifiedDate      = customerBank.ModifiedDate;
            }
            return(customerBankDto);
        }
예제 #7
0
        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);
        }
예제 #8
0
 public static void ConvertToCustomerBankEntity(ref CustomerBank customerBank, CustomerBankDTO customerBankDto, bool isUpdate)
 {
     customerBank.CustomerId = customerBankDto.CustomerId;
     if (String.IsNullOrWhiteSpace(customerBankDto.IFSCCode) == false)
     {
         customerBank.IFSCCode = customerBankDto.IFSCCode;
     }
     if (String.IsNullOrWhiteSpace(customerBankDto.AccountNo) == false)
     {
         customerBank.AccountNo = customerBankDto.AccountNo;
     }
     if (String.IsNullOrWhiteSpace(customerBankDto.Branch) == false)
     {
         customerBank.Branch = customerBankDto.Branch;
     }
     if (String.IsNullOrWhiteSpace(customerBankDto.BankName) == false)
     {
         customerBank.BankName = customerBankDto.BankName;
     }
     if (String.IsNullOrWhiteSpace(customerBankDto.AccountHolderName) == false)
     {
         customerBank.AccountHolderName = customerBankDto.AccountHolderName;
     }
     if (String.IsNullOrWhiteSpace(customerBankDto.UPIId) == false)
     {
         customerBank.UPIId = customerBankDto.UPIId;
     }
 }