Beispiel #1
0
        public void AddToDiv(CMSDataContext Db, int divid)
        {
            var divorg = DivOrgs.SingleOrDefault(d => d.DivId == divid);

            if (divorg == null)
            {
                DivOrgs.Add(new DivOrg {
                    DivId = divid
                });
            }
        }
Beispiel #2
0
        public void SetTagString(CMSDataContext Db, string value)
        {
            if (!value.HasValue())
            {
                Db.DivOrgs.DeleteAllOnSubmit(DivOrgs);
                return;
            }
            var a       = value.Split(',');
            var qdelete = from d in DivOrgs
                          where !a.Contains(d.Division.Name)
                          select d;

            Db.DivOrgs.DeleteAllOnSubmit(qdelete);

            var q = from s in a
                    join d2 in DivOrgs on s equals d2.Division.Name into g
                    from d in g.DefaultIfEmpty()
                    where d == null
                    select s;

            foreach (var s in q)
            {
                var div = Db.Divisions.FirstOrDefault(d => d.Name == s);
                if (div == null)
                {
                    div = new Division {
                        Name = s
                    };
                    string misctags = Db.Setting("MiscTagsString", "Misc Tags");
                    var    prog     = Db.Programs.SingleOrDefault(p => p.Name == misctags);
                    if (prog == null)
                    {
                        prog = new Program {
                            Name = misctags
                        };
                        Db.Programs.InsertOnSubmit(prog);
                    }
                    div.Program = prog;
                }
                DivOrgs.Add(new DivOrg {
                    Division = div
                });
            }
            _TagString = value;
        }
Beispiel #3
0
        public bool ToggleTag(CMSDataContext Db, int divid)
        {
            var divorg = DivOrgs.SingleOrDefault(d => d.DivId == divid);

            if (divorg == null)
            {
                DivOrgs.Add(new DivOrg {
                    DivId = divid
                });
                return(true);
            }
            if (DivOrgs.Count == 1)
            {
                return(true);
            }
            DivOrgs.Remove(divorg);
            Db.DivOrgs.DeleteOnSubmit(divorg);
            return(false);
        }