// Edit Payment by Id public bool UpdatePayingBy(int id, PayingByEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Payments.SingleOrDefault(e => e.PayById == id); entity.CashOrCard = model.CashOrCard; return(ctx.SaveChanges() == 1); } }
//Get: PayingBy/Edit/{id} public ActionResult Edit(int id) { var service = new PayingByService(); var detail = service.GetPayingBy(id); var payingBy = new PayingByEdit() { CashOrCard = detail.CashOrCard }; return(View(payingBy)); }
public ActionResult Edit(int id, PayingByEdit model) { var service = new PayingByService(); if (!ModelState.IsValid) { return(View(model)); } if (service.UpdatePayingBy(id, model)) { TempData["SaveResult"] = "Payment Updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Payment could not be updated"); return(View(model)); }