public ActionResult Create(ProjectSubjectDTO entity) { var errors = "B000"; string message = string.Empty; if (Const.IsNullOrEmpty(entity.Name)) { errors = "B001"; message = "项目专业名称不能为空。"; } using (DataClassesDataContext data = new DataClassesDataContext()) { if (data.ProjectSubjectDTO.Where(u => u.Name == entity.Name).Count() > 0) { errors = "B002"; message = "项目专业已经存在。"; } else { data.ProjectSubjectDTO.InsertOnSubmit(entity); data.SubmitChanges(); } } var retval = new { success = (errors == "B000"), errors = errors, message = message }; return Json(retval, "text/html", JsonRequestBehavior.AllowGet); }
partial void UpdateProjectSubjectDTO(ProjectSubjectDTO instance);
partial void DeleteProjectSubjectDTO(ProjectSubjectDTO instance);
partial void InsertProjectSubjectDTO(ProjectSubjectDTO instance);