public WhitelistPresentationStub(Crew_Whitelist dbItem) { this.Id = dbItem.Id; this.Barcode = dbItem.Barcode; this.TanggalAwal = (DateTime)dbItem.Tanggal_Awal; this.TanggalAkhir = (DateTime)dbItem.Tanggal_Akhir; }
public WhitelistFormStub(Crew_Whitelist dbItem) { Id = dbItem.Id; Barcode = dbItem.Barcode; TanggalAwal = (DateTime)dbItem.Tanggal_Awal; TanggalAkhir = (DateTime)dbItem.Tanggal_Akhir; }
public ActionResult EditWhitelist(WhitelistFormStub model) { //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0; if (ModelState.IsValid) { Crew_Whitelist dbItem = RepoWhite.FindByPk(model.Id); dbItem = model.GetDbObject(dbItem); try { RepoWhite.Save(dbItem); } catch (Exception e) { return(View("FormCrew", model)); } //message string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString(); this.SetMessage(model.Id.ToString(), template); return(View("CrewWhitelist")); } else { return(View("FormWhitelist", model)); } }
public Crew_Whitelist GetDbObject(Crew_Whitelist dbItem) { dbItem.Id = this.Id; dbItem.Barcode = this.Barcode; dbItem.Tanggal_Awal = this.TanggalAwal; dbItem.Tanggal_Akhir = this.TanggalAkhir; return(dbItem); }
public JsonResult DeleteWhitelist(int id) { string template = ""; ResponseModel response = new ResponseModel(true); Crew_Whitelist dbItem = RepoWhite.FindByPk(id); RepoWhite.Delete(dbItem); return(Json(response)); }
public void Save(Crew_Whitelist dbItem) { if (dbItem.Id == 0) //create { context.Crew_Whitelist.Add(dbItem); } else //edit { var entry = context.Entry(dbItem); entry.State = EntityState.Modified; } context.SaveChanges(); }
public ActionResult EditWhitelist(int id) { Crew_Whitelist white = RepoWhite.FindByPk(id); List <object> newList = new List <object>(); foreach (var crew in context.Crews) { newList.Add(new { Id = crew.Barcode, Name = crew.Barcode + " " + crew.Nama }); } this.ViewData["Crew"] = new SelectList(newList, "Name", "Id"); WhitelistFormStub formStub = new WhitelistFormStub(white); return(View("FormWhitelist", formStub)); }
public void Delete(Crew_Whitelist dbItem) { context.Crew_Whitelist.Remove(dbItem); context.SaveChanges(); }