public ActionResult Update(KPI model) { model.id = model.id > 0 ? -model.id : model.id; if (ModelState.IsValid) { var user = User.Identity.Name.Split('@')[0]; var KPI = db.KPIs.Find(model.id); if (KPI.Email != user && KPI.KP1.Email != user) { return(HttpNotFound()); } KPI.MucTieu = model.MucTieu; KPI.TyTrong = model.TyTrong; KPI.ChiTieu = model.ChiTieu; KPI.DonViTinh = model.DonViTinh; KPI.GhiChu = model.GhiChu; KPI.Email = model.Email ?? user; db.Entry(KPI).State = EntityState.Modified; LogInfo(model); db.SaveChanges(); return(RedirectToAction("Details", new { id = -KPI.idKPI })); } ViewBag.Names = db.KpiUsers.First().Names; return(View(db.KPIs.Find(model.id))); }
public ActionResult Edit([Bind(Include = "KPM_ID,KPM_Event,KPM_FPercent,KPM_SPercent,KPY_ID")] kpi_Perfomance kpi_Perfomance) { if (ModelState.IsValid) { db.Entry(kpi_Perfomance).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.KPY_ID = new SelectList(db.kpi_Year, "KPY_ID", "KPY_Name", kpi_Perfomance.KPY_ID); return(View(kpi_Perfomance)); }