Example #1
0
        public void AddRemoveDiv()
        {
            var d = DbUtil.Db.DivOrgs.SingleOrDefault(dd => dd.DivId == TargetDivision && dd.OrgId == Id);

            if (Adding && d == null && TargetDivision.HasValue)
            {
                d = new DivOrg {
                    OrgId = Id, DivId = TargetDivision.Value
                };
                DbUtil.Db.DivOrgs.InsertOnSubmit(d);
                DbUtil.Db.SubmitChanges();
            }
            else if (!Adding && d != null)
            {
                DbUtil.Db.DivOrgs.DeleteOnSubmit(d);
                DbUtil.Db.SubmitChanges();
            }
            Page = 1;
        }
        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());
        }