public ActionResult AddNewHP(FormCollection form) { HOCPHAN hp = new HOCPHAN(); hp.TenHP = form["TenHP"]; hp.SoTC = int.Parse(form["SoTC"]); hp.HSDiemThi = Math.Round(float.Parse(form["HSDiemThi"]), 1); db.HOCPHANs.Add(hp); db.SaveChanges(); var listHP = db.HOCPHANs.ToList(); return(View("Index_List_HP", listHP)); }
public ActionResult UpdateHP(FormCollection form) { int ma = int.Parse(form["MaHP"]); HOCPHAN hp = (from h in db.HOCPHANs where h.MaHP == ma select h).FirstOrDefault(); hp.TenHP = form["TenHP"]; hp.SoTC = int.Parse(form["SoTC"]); hp.HSDiemThi = Math.Round(float.Parse(form["HSDiemThi"]), 1); db.SaveChanges(); var listHP = db.HOCPHANs.ToList(); return(View("Index_List_HP", listHP)); }