public ActionResult Edit(int id) { LookupCode model = new LookupCode(RepoLookup.FindByPK(id)); ViewBag.name = model.Nama; return(View("Form", model)); }
public JsonResult Delete(int id) { ResponeModel response = new ResponeModel(true); Context.LookupCode dbItem = RepoLookup.FindByPK(id); RepoLookup.delete(dbItem); return(Json(response)); }
public ActionResult Edit(LookupCode model) { if (ModelState.IsValid) { Context.LookupCode dbitem = RepoLookup.FindByPK(model.Id); model.setDb(dbitem); RepoLookup.save(dbitem); return(RedirectToAction("Index")); } return(View("Form", model)); }
public ActionResult Add(DataBox model) { if (ModelState.IsValid) { if (RepoDataBox.IsBoxExist(model.IdDataTruck.Value)) { ModelState.AddModelError("IdDataTruck", "Truck sudah tepasang box, harap ganti dengan truck yang lain"); return(View("Form", model)); } Context.DataBox dbitem = new Context.DataBox(); model.SetDb(dbitem); //generate code dbitem.Urutan = RepoDataBox.getUrutan() + 1; dbitem.NoBox = RepoDataBox.generateCode(dbitem.Urutan); Context.DataBoxHistory dbitemHistory = new Context.DataBoxHistory(); model.SetDbHistory(dbitemHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname); dbitemHistory.Vehicle = RepoDataTruck.FindByPK(model.IdDataTruck.Value).VehicleNo; dbitemHistory.NoBox = dbitem.NoBox; dbitemHistory.strKategori = model.IdKategori.HasValue ? RepoLookup.FindByPK(model.IdKategori.Value).Nama : ""; dbitemHistory.strType = model.IdType.HasValue ? RepoLookup.FindByPK(model.IdType.Value).Nama : ""; dbitem.DataBoxHistory.Add(dbitemHistory); Context.DataTruckBoxHistory dbtruckHistory = new Context.DataTruckBoxHistory(); model.SetDbTruckHistory(dbtruckHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname); RepoDataBox.save(dbitem, UserPrincipal.id, dbitemHistory, dbtruckHistory); Context.DataTruck dbtruck = RepoDataTruck.FindByPK(model.IdDataTruck.Value); dbtruckHistory.Vehicle = dbtruck.VehicleNo; dbtruckHistory.NoBox = dbitem.NoBox; dbtruckHistory.strKategori = model.IdKategori.HasValue ? RepoLookup.FindByPK(model.IdKategori.Value).Nama : ""; dbtruckHistory.strType = model.IdType.HasValue ? RepoLookup.FindByPK(model.IdType.Value).Nama : ""; dbtruck.DataTruckBoxHistory.Add(dbtruckHistory); RepoDataTruck.save(dbtruck, UserPrincipal.id); return(RedirectToAction("Index")); } return(View("Form", model)); }
public ActionResult Add(DataPendingin model) { if (ModelState.IsValid) { if (RepoPendingin.IsBoxExist(model.IdDataTruk.Value)) { ModelState.AddModelError("IdDataTruk", "Truck sudah tepasang pendingin, harap ganti dengan truck yang lain"); return(View("Form", model)); } Context.DataPendingin dbitem = new Context.DataPendingin(); model.setDb(dbitem); //generate code dbitem.Urutan = RepoPendingin.getUrutan() + 1; dbitem.NoPendingin = RepoPendingin.generateCode(dbitem.Urutan); Context.DataPendinginHistory dbitemhistory = new Context.DataPendinginHistory(); model.setDbHistory(dbitemhistory, UserPrincipal.firstname + ' ' + UserPrincipal.lastname); dbitemhistory.NoPendingin = dbitem.NoPendingin; dbitemhistory.strDataTruk = RepoDataTruck.FindByPK(dbitem.IdDataTruk).VehicleNo; dbitemhistory.strJenisPendingin = dbitem.IdJenisPendingin.HasValue ? RepoLookup.FindByPK(dbitem.IdJenisPendingin).Nama : ""; dbitem.ListHistoryPendingin.Add(dbitemhistory); Context.DataTruckPendinginHistory dbtruckhistory = new Context.DataTruckPendinginHistory(); model.setDbTruckHistory(dbtruckhistory, UserPrincipal.firstname + ' ' + UserPrincipal.lastname); RepoPendingin.save(dbitem, UserPrincipal.id, dbitemhistory, dbtruckhistory); Context.DataTruck dbtruck = RepoDataTruck.FindByPK(model.IdDataTruk.Value); dbtruckhistory.NoPendingin = dbitem.NoPendingin; dbtruckhistory.strDataTruk = RepoDataTruck.FindByPK(dbitem.IdDataTruk).VehicleNo; dbtruckhistory.strJenisPendingin = dbitem.IdJenisPendingin.HasValue ? RepoLookup.FindByPK(dbitem.IdJenisPendingin).Nama : ""; dbtruck.DataTruckPendinginHistory.Add(dbtruckhistory); RepoDataTruck.save(dbtruck, UserPrincipal.id); return(RedirectToAction("Index")); } return(View("Form", model)); }