public ActionResult Edit(OnlinePaying onlinePaying) { if (ModelState.IsValid) { var service = new OnlinePayingService(); var result = service.Update(onlinePaying); if (result) { SetAlert("Cập nhật thanh toán trực tiếp thành công!", "success"); return(RedirectToAction("Index", "OnlinePayingAdmin")); } else { ModelState.AddModelError("", "Cập nhật thanh toán trực tuyến thất bại!"); } } SetViewBagMethod(onlinePaying.Method); return(View("Index")); }
public ActionResult CreateOnline(OnlinePaying onlinePaying) { if (ModelState.IsValid) { var service = new OnlinePayingService(); int id = service.Insert(onlinePaying); if (id > 0) { SetAlert("Thêm thanh toán trực tiếp thành công!", "success"); return(RedirectToAction("Index", "OnlinePayingAdmin")); } else { ModelState.AddModelError("", "Thêm thanh toán trực tuyến mới thất bại!"); } } SetViewBagMethod(onlinePaying.Method); return(View("Index")); }
public bool Update(OnlinePaying entity) { try { var onlinePaying = db.OnlinePayings.Find(entity.ID); onlinePaying.Method = entity.Method; onlinePaying.NamePay = entity.NamePay; onlinePaying.NameAccount = entity.NameAccount; onlinePaying.CodeAccount = entity.CodeAccount; onlinePaying.Address = entity.Address; onlinePaying.CreatedBy = entity.CreatedBy; onlinePaying.CreatedDate = DateTime.Now; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public int Insert(OnlinePaying entity) { db.OnlinePayings.Add(entity); db.SaveChanges(); return(entity.ID); }