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")); }