public int? CreateUpdateCustomerPayment(CustomerPaymentViewModel customerPaymentViewModel)
        {
            CustomerPayment customerPayment = null;

            if (customerPaymentViewModel.CustomerPaymentId > 0)
            {
                customerPayment = _repository.Find<CustomerPayment>(x => x.CustomerPaymentId == customerPaymentViewModel.CustomerPaymentId);
                if (customerPayment == null)
                    return null;

                customerPayment.InvoiceId = customerPaymentViewModel.InvoiceId;
                customerPayment.CustomerId = customerPaymentViewModel.CustomerId;
                customerPayment.PaymentDate = customerPaymentViewModel.PaymentDate;
                customerPayment.Amount = customerPaymentViewModel.Amount;
                customerPayment.Comments = customerPaymentViewModel.Comments;
                customerPayment.ModifiedBy = customerPaymentViewModel.ModifiedBy;
                customerPayment.ModifiedDate = DateTime.Now;

                _repository.Modify<CustomerPayment>(customerPayment);
                return customerPayment.CustomerPaymentId;
            }

            Mapper.CreateMap<CustomerPaymentViewModel, CustomerPayment>();
            customerPayment = Mapper.Map<CustomerPaymentViewModel, CustomerPayment>(customerPaymentViewModel);

            customerPayment.CreatedDate = DateTime.Now;
            customerPayment.CreatedBy = customerPaymentViewModel.CreatedBy;
            customerPayment.IsDeleted = false;
            return _repository.Insert<CustomerPayment>(customerPayment);
        }
        public ActionResult CreateUpdateCustomerPayment(CustomerPaymentViewModel customerPaymentViewModel)
        {
           
                ActiveUser activeUser = new JavaScriptSerializer().Deserialize<ActiveUser>(System.Web.HttpContext.Current.User.Identity.Name);
                customerPaymentViewModel.CreatedBy = activeUser.UserId;
                customerPaymentViewModel.ModifiedBy = activeUser.UserId;

                var result = _customerPaymentComponent.CreateUpdateCustomerPayment(customerPaymentViewModel);

                return Json(result, JsonRequestBehavior.AllowGet);
            
        }
 public ActionResult CreateUpdateCustomerPaymentPopup(int id)
 {
     var customerPayment = _customerPaymentComponent.GetCustomerPayment(id);
     if (customerPayment == null)
         customerPayment = new CustomerPaymentViewModel();
     customerPayment.CustomerList = new SelectList(_customerComponent.GetAllCustomer(), "CustomerId", "NameEmail");
     //customerPayment.InvoiceList = new SelectList(_customerInvoiceComponent.GetAllCustomerInvoice(), "InvoiceId", "InvoiceNo");
     return PartialView("/Views/Shared/Partials/_CustomerPayment.cshtml", customerPayment);
 }