public List <SellerInstallmentModel> DeleteSellerInstallment(long Id, long sellerID) { List <SellerInstallmentModel> lstinstallments = new List <SellerInstallmentModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { SellerInstallment installment = GetSellerInstallment(db, Id); db.SellerInstallments.Remove(installment); db.SaveChanges(); var lstproducts = db.SellerInstallments.Where(m => m.SellerID == sellerID).ToList(); foreach (var cusprod in lstproducts) { SellerInstallmentModel objInstallments = new SellerInstallmentModel(); cusprod.CopyProperties(objInstallments); lstinstallments.Add(objInstallments); } } catch (Exception) { } return(lstinstallments); } }
public SellerInstallment GetSellerInstallment(ShopDevEntities db, long Id) { SellerInstallment objinstllment = null; try { objinstllment = db.SellerInstallments.Where(m => m.SellerInstallmentID == Id).FirstOrDefault(); } catch (Exception) { } return(objinstllment); }
public List <SellerInstallmentModel> AddSellerInstallment(SellerInstallmentModel installment) { List <SellerInstallmentModel> lstAllinstallments = new List <SellerInstallmentModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { installment.SellerID = installment.SellerID == null ? 0 : installment.SellerID; SellerInstallment sellerinstDetail = null; if (installment.SellerInstallmentID > 0) { sellerinstDetail = db.SellerInstallments.Where(m => m.SellerInstallmentID == installment.SellerInstallmentID).FirstOrDefault(); } else { sellerinstDetail = new SellerInstallment(); } installment.CopyProperties(sellerinstDetail); if (sellerinstDetail.SellerInstallmentID == 0) { db.SellerInstallments.Add(sellerinstDetail); } db.SaveChanges(); var lstinstallments = db.SellerInstallments.Where(m => m.SellerID == installment.SellerID).ToList(); foreach (var cusprod in lstinstallments) { SellerInstallmentModel objcsproduct = new SellerInstallmentModel(); cusprod.CopyProperties(objcsproduct); lstAllinstallments.Add(objcsproduct); } } catch { } return(lstAllinstallments); } }