Exemple #1
0
        public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division)
        {
            var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division && pp.ProgDivs.Any(pd => pd.ProgId == program.Id));

            if (d == null)
            {
                d = new Division {
                    Name = division, Program = program
                };
                var progdiv = new ProgDiv {
                    Division = d, Program = program
                };
                Db.ProgDivs.InsertOnSubmit(progdiv);
                Db.SubmitChanges();
            }
            else
            {
                var pd = Db.ProgDivs.SingleOrDefault(dd => dd.ProgId == program.Id && dd.DivId == d.Id);
                if (pd == null)
                {
                    program.Divisions.Add(d);
                }
                Db.SubmitChanges();
            }
            return(d);
        }
Exemple #2
0
        public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division)
        {
            var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division);

            if (d == null)
            {
                d = new Division {
                    Name = division, Program = program
                };
                var progdiv = new ProgDiv {
                    Division = d, Program = program
                };
                Db.ProgDivs.InsertOnSubmit(progdiv);
                Db.SubmitChanges();
            }
            return(d);
        }
Exemple #3
0
 public static Division FetchOrCreateDivision(CMSDataContext Db, Program program, string division)
 {
     var d = Db.Divisions.SingleOrDefault(pp => pp.Name == division && pp.ProgDivs.Any(pd => pd.ProgId == program.Id));
     if (d == null)
     {
         d = new Division { Name = division, Program = program };
         var progdiv = new ProgDiv { Division = d, Program = program };
         Db.ProgDivs.InsertOnSubmit(progdiv);
         Db.SubmitChanges();
     }
     else
     {
         var pd = Db.ProgDivs.SingleOrDefault(dd => dd.ProgId == program.Id && dd.DivId == d.Id);
         if (pd == null)
             program.Divisions.Add(d);
         Db.SubmitChanges();
     }
     return d;
 }
Exemple #4
0
 private void detach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Division = null;
 }
Exemple #5
0
 private void attach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Division = this;
 }
Exemple #6
0
 private void detach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Program = null;
 }
Exemple #7
0
 private void attach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Program = this;
 }