/// <summary> /// 修改或者添加学校 /// </summary> /// <param name="info"></param> /// <returns></returns> public ActionResult AddOrUpdate(Models.Schools info) { try { if (string.IsNullOrEmpty(info.School_Remark)) { info.School_Remark = ""; } if (info.School_ID != 0) //修改 { Models.Schools school = ent.Schools.FirstOrDefault(m => m.School_ID == info.School_ID); UpdateModel(school); ent.SaveChanges(); return(Content("update")); } else //新增 { ent.Schools.Add(info); ent.SaveChanges(); return(Content("add")); } } catch (Exception ex) { return(Content(ex.Message.ToString())); } }
/// <summary> /// 删除学校 /// </summary> /// <param name="sID"></param> /// <returns></returns> public ActionResult Del(int?sID) { try { Models.Schools info = ent.Schools.FirstOrDefault(m => m.School_ID == sID); ent.Schools.Remove(info); ent.SaveChanges(); return(Content("true")); } catch (Exception ex) { return(Content(ex.Message.ToString())); } }