private void ValidateModel(Quanlichitieu model) { if (model.Total <= 0) { ModelState.AddModelError("Total", "Số tiền quá ít!"); } }
public ActionResult DeleteConfirmed(int id) { Quanlichitieu quanlichitieu = db.Quanlichitieux.Find(id); db.Quanlichitieux.Remove(quanlichitieu); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,Date,Total,Detail")] Quanlichitieu quanlichitieu) { if (ModelState.IsValid) { db.Entry(quanlichitieu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(quanlichitieu)); }
public ActionResult Create(Quanlichitieu model) { ValidateModel(model); if (ModelState.IsValid) { model.Date = DateTime.Today; db.Quanlichitieux.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
// GET: /quanli/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Quanlichitieu quanlichitieu = db.Quanlichitieux.Find(id); if (quanlichitieu == null) { return(HttpNotFound()); } return(View(quanlichitieu)); }