public ActionResult Create(int? id) { if (!id.HasValue) return Content("need an integer id"); var m = new MemberType { Id = id.Value }; DbUtil.Db.MemberTypes.InsertOnSubmit(m); DbUtil.Db.SubmitChanges(); return Redirect("/MemberType/"); }
public ActionResult Create(int? id) { if (!id.HasValue) return Content("need an integer id"); if (!DbUtil.Db.MemberTypes.Any(mt => mt.Id == id)) { var m = new MemberType {Id = id.Value}; DbUtil.Db.MemberTypes.InsertOnSubmit(m); DbUtil.Db.SubmitChanges(); } return Redirect($"/MemberType/#{id}"); }
public static MemberType FetchOrCreateMemberType(CMSDataContext Db, string type) { var mt = Db.MemberTypes.SingleOrDefault(pp => pp.Description == type); if (mt == null) { var max = Db.MemberTypes.Max(mm => mm.Id) + 10; if (max < 1000) max = 1010; mt = new MemberType { Id = max, Description = type, Code = type.Truncate(20), AttendanceTypeId = AttendTypeCode.Member }; Db.MemberTypes.InsertOnSubmit(mt); Db.SubmitChanges(); } return mt; }
private void detach_MemberTypes(MemberType entity) { this.SendPropertyChanging(); entity.AttendType = null; }