public ActionResult Edit(BAP model) { if (ModelState.IsValid) { Context.BAP dbitem = RepoBAP.FindByPK(model.Id); bool Isexist = RepoBAP.IsExist(model.SOBapId, model.SOBapKontrakId, model.Driver1Id, model.IdDataTruck, model.KategoriId, model.Id); if (Isexist) { ModelState.AddModelError("NoBAP", "BAP telah dipakai."); return(View("Form", model)); } model.setDb(dbitem); RepoBAP.save(dbitem, UserPrincipal.id); return(RedirectToAction("Index")); } return(View("Form", model)); }
public ActionResult Add(BAP model) { if (ModelState.IsValid) { int seq = RepoBAP.getUrutanOnCAll(model.TanggalKejadian.Value); model.NoBAP = RepoBAP.GenerateCode(model.TanggalKejadian.Value, seq); bool Isexist = RepoBAP.IsExist(model.SOBapId, model.SOBapKontrakId, model.Driver1Id, model.IdDataTruck, model.KategoriId, model.Id); if (Isexist) { ModelState.AddModelError("NoBAP", "BAP telah dipakai."); return(View("Form", model)); } Context.BAP dbitem = new Context.BAP(); model.setDb(dbitem); RepoBAP.save(dbitem, UserPrincipal.id); return(RedirectToAction("Index")); } return(View("Form", model)); }