public ActionResult Update(文型_Table model) { try { var b = model.文型; b = b.Replace("<", "<ruby>"); b = b.Replace(">", "</ruby>"); b = b.Replace("{", "<rt>"); b = b.Replace("}", "</rt>"); model.文型 = b; db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ModelState.Clear(); ModelState.AddModelError("", "Update thành công!"); } catch { ModelState.AddModelError("", "Update thất bại!"); } ViewBag.第課List = new SelectList(db.第課_Table, "第課ID", "第課Name"); return(View("Index")); }
public ActionResult Insert(文型_Table model) { try { var b = model.文型; b = b.Replace("<", "<ruby>"); b = b.Replace(">", "</ruby>"); b = b.Replace("{", "<rt>"); b = b.Replace("}", "</rt>"); model.文型 = b; db.文型_Table.Add(model); db.SaveChanges(); ModelState.Clear(); ModelState.AddModelError("", "Thêm thành công!"); } catch { ModelState.AddModelError("", "Thêm thất bại!"); } ViewBag.第課List = new SelectList(db.第課_Table, "第課ID", "第課Name"); return(View("Index")); }