public ActionResult CreateCrew() { CrewFormStub formStub = new CrewFormStub(); return View("FormCrew", formStub); }
public ActionResult EditCrew(string barcode) { Crew crew = RepoCrew.FindByPk(barcode); CrewFormStub formStub = new CrewFormStub(crew); return View("FormCrew", formStub); }
public ActionResult EditCrew(CrewFormStub model) { //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0; if (ModelState.IsValid) { Crew dbItem = RepoCrew.FindByPk(model.Barcode); dbItem = model.GetDbObject(dbItem); try { RepoCrew.Save(dbItem); } catch (Exception e) { return View("FormCrew", model); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.NamaCrew, template); return View("CrewCRUD"); } else { return View("FormCrew", model); } }
public ActionResult CreateCrew(CrewFormStub model) { //bool isNameExist = RepoContractor.Find().Where(p => p.name == model.Name).Count() > 0; if (ModelState.IsValid) { Crew dbItem = new Crew(); dbItem = model.GetDbObject(dbItem); //Generate ID untuk Crew string barcode = DateTime.Now.ToString("ddMMyyyy"); dbItem.Barcode = barcode + "-" + (RepoCrew.FindAll().Count + 1).ToString("D3"); try { RepoCrew.Save(dbItem); } catch (Exception e) { return View("FormCrew", model); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.NamaCrew, template); return RedirectToAction("CrewCRUD"); } else { return View("FormCrew", model); } }