public ActionResult AddRemoveDiv(int id, int divid, bool ischecked) { var d = DbUtil.Db.DivOrgs.SingleOrDefault(dd => dd.DivId == divid && dd.OrgId == id); if (ischecked && d == null) { d = new DivOrg { OrgId = id, DivId = divid }; DbUtil.Db.DivOrgs.InsertOnSubmit(d); DbUtil.Db.SubmitChanges(); } if (!ischecked && d != null) { DbUtil.Db.DivOrgs.DeleteOnSubmit(d); DbUtil.Db.SubmitChanges(); } return new EmptyResult(); }
private void detach_DivOrgs(DivOrg entity) { this.SendPropertyChanging(); entity.Division = null; }
private void attach_DivOrgs(DivOrg entity) { this.SendPropertyChanging(); entity.Division = this; }