private static PaymentInvoiceLines getEntityByModel(PaymentInvoiceLinesModel model) { if (model == null) { return(null); } PaymentInvoiceLines entity = new PaymentInvoiceLines { Amount = model.Amount, PaymentId = model.PaymentId, InvoiceId = model.InvoiceId, Id = model.Id }; if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
public static void DeletePaymentLine(PaymentInvoiceLinesModel model) { PaymentViewModel header = SessionHelper.Payment; PaymentInvoiceLinesModel paymentLine = header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id); header.PaymentInvoiceLines.Remove(paymentLine); }
public static void UpdatePaymentLine(PaymentInvoiceLinesModel model) { PaymentViewModel header = SessionHelper.Payment; header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id).Amount = model.Amount; header.PaymentInvoiceLines.FirstOrDefault(x => x.Id == model.Id).InvoiceId = model.InvoiceId; }
public ActionResult AddNewPartial(PaymentInvoiceLinesModel model) { if (ModelState.IsValid) { try { bool validated = false; if (SessionHelper.Payment != null) { if (SessionHelper.Payment.BankAccountId == 0) { ViewData["EditError"] = "Please select Bank Account"; return(PartialView("createPartial", PaymentHelper.GetPaymentLines())); } if (SessionHelper.Payment.VendorSiteId == 0) { ViewData["EditError"] = "Please select Vendor Site"; return(PartialView("createPartial", PaymentHelper.GetPaymentLines())); } model.Id = SessionHelper.Payment.PaymentInvoiceLines.Last().Id + 1; validated = true; } else { model.Id = 1; } if (validated) { PaymentHelper.Insert(model); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", PaymentHelper.GetPaymentLines())); }
public ActionResult UpdatePartial(PaymentInvoiceLinesModel model) { if (ModelState.IsValid) { try { PaymentHelper.UpdatePaymentLine(model); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", PaymentHelper.GetPaymentLines())); }
public ActionResult DeletePartial(PaymentInvoiceLinesModel model) { if (ModelState.IsValid) { try { PaymentViewModel header = SessionHelper.Payment; PaymentHelper.DeletePaymentLine(model); SessionHelper.Payment = header; IList <PaymentInvoiceLinesModel> paymentLines = PaymentHelper.GetPaymentLines(); return(PartialView("createPartial", paymentLines)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public static void Insert(PaymentInvoiceLinesModel model) { PaymentViewModel header = SessionHelper.Payment; header.PaymentInvoiceLines.Add(model); }