public int Insert(CustomerPaymentDetail obj) { CustomerPaymentDetail newCustomerPaymentDetail = new CustomerPaymentDetail(); newCustomerPaymentDetail.cust_Id = obj.cust_Id; newCustomerPaymentDetail.balanceAmount = obj.balanceAmount; newCustomerPaymentDetail.PaidAmount = obj.PaidAmount; newCustomerPaymentDetail.date = obj.date; newCustomerPaymentDetail.received = obj.received; newCustomerPaymentDetail.remark = obj.remark; if (obj.signature != null) { newCustomerPaymentDetail.signature = obj.signature; } context.CustomerPaymentDetails.Add(newCustomerPaymentDetail); context.SaveChanges(); CustomerDetail objCustomerDetails = context.CustomerDetails.Where(ite => ite.cust_id == obj.cust_Id).FirstOrDefault(); if (objCustomerDetails != null) { objCustomerDetails.openingBalance = objCustomerDetails.openingBalance - obj.PaidAmount; context.SaveChanges(); } return(newCustomerPaymentDetail.cust_Id); }
public void Delete(int id) { CustomerPaymentDetail newCustomerPaymentDetail = context.CustomerPaymentDetails.Where(obj => obj.cust_Id == id).FirstOrDefault(); context.CustomerPaymentDetails.Where(obj => obj.cust_Id == id).ToList().ForEach(obj => context.CustomerPaymentDetails.Remove(obj)); context.CustomerPaymentDetails.Remove(newCustomerPaymentDetail); context.SaveChanges(); }
public void Update(CustomerPaymentDetail obj) { CustomerPaymentDetail newCustomerPaymentDetail = new CustomerPaymentDetail(); newCustomerPaymentDetail.cust_Id = obj.cust_Id; newCustomerPaymentDetail.balanceAmount = obj.balanceAmount; newCustomerPaymentDetail.PaidAmount = obj.PaidAmount; newCustomerPaymentDetail.date = obj.date; newCustomerPaymentDetail.received = obj.received; newCustomerPaymentDetail.remark = obj.remark; newCustomerPaymentDetail.signature = obj.signature; context.CustomerPaymentDetails.Add(newCustomerPaymentDetail); context.SaveChanges(); }