public ActionResult Edit(int id = 0) { List <DDLInspector> result = new List <DDLInspector>(); tt_DailyView edited = new tt_DailyView(); using (HELLOWEntities db = new HELLOWEntities()) { result = (from inspect in db.tm_Recorder where inspect.Status_FK == 1 select new DDLInspector { inspectpk = inspect.Recorder_PK, Text = inspect.Nama + "(" + inspect.NoRecorder + ")" }).ToList(); ViewBag.Testlist = result; edited = (from dail in db.tt_Daily where dail.Daily_PK == id select new tt_DailyView { Daily_PK = dail.Daily_PK, Datetemp = dail.Date, Recorder_FK = dail.Recorder_FK, SheetNum = dail.SheetNum }).FirstOrDefault(); edited.Date = edited.Datetemp.ToString("dd MMMM yyyy"); return(PartialView(edited)); } }
public ActionResult Edit(tt_DailyView td) { DateTime temp; using (HELLOWEntities db = new HELLOWEntities()) { tt_Daily dail = db.tt_Daily.Where(x => x.Daily_PK == td.Daily_PK).FirstOrDefault <tt_Daily>(); if (DateTime.TryParse(td.Date, out temp)) { dail.Date = temp; dail.Recorder_FK = td.Recorder_FK; dail.SheetNum = td.SheetNum; } db.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } }