Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #4
0
 private void detach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Division = null;
 }
Beispiel #5
0
 private void attach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Division = this;
 }
Beispiel #6
0
 private void detach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Program = null;
 }
Beispiel #7
0
 private void attach_ProgDivs(ProgDiv entity)
 {
     this.SendPropertyChanging();
     entity.Program = this;
 }