public ActionResult Create(InvoiceMaster invoicemaster) { invoicemaster.DateCreated = DateTime.Now; invoicemaster.DateModified = DateTime.Now; invoicemaster.InvoiceDetail.DateCreated = DateTime.Now; invoicemaster.InvoiceDetail.DateModified = DateTime.Now; invoicemaster.InvoiceDetail.IdInvoiceMaster = invoicemaster.IdInvoiceMaster; invoicemaster.State = true; var member = db.Members.Find(invoicemaster.IdMember); member.TotalAmountDue += invoicemaster.InvoiceDetail.Price; member.Invoices.Add(invoicemaster); if (ModelState.IsValid) { db.InvoiceMasters.Add(invoicemaster); db.Entry(member).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType", invoicemaster.IdInvoiceType); ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", invoicemaster.IdMember); return View(invoicemaster); }
// // GET: /InvoiceMaster/Create public ActionResult Create() { InvoiceMaster invoiceMaster = new InvoiceMaster(); invoiceMaster.DateInvoiceMaster = DateTime.Now; ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType"); ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber"); ViewBag.IdChargeCode = new SelectList(db.ChargeCodes, "IdChargeCode", "NameChargeCode"); return View(invoiceMaster); }
public ActionResult Edit(InvoiceMaster invoicemaster) { if (ModelState.IsValid) { db.Entry(invoicemaster).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IdInvoiceType = new SelectList(db.InvoiceTypes, "IdInvoiceType", "NameInvoiceType", invoicemaster.IdInvoiceType); ViewBag.IdMember = new SelectList(db.Members, "IdMember", "MemberNumber", invoicemaster.IdMember); return View(invoicemaster); }
public void Update(InvoiceMaster invoiceMaster) { _db.Entry(invoiceMaster).State = EntityState.Modified; _db.SaveChanges(); }