Ejemplo n.º 1
0
 //собственно алгоритм
 public void Create()
 {
     Building.PreBuild();
     Building.Build();
     for (int i = 0; i < Building.Classes.Count; i++)
     {
         for (int j = 0; j < Building.Orders.Count; j++)
         {
             Shedule sh = new Shedule();
             sh.Couple_ID = Building.Classes[i].Couple;
             sh.DayOfWeek = Building.Classes[i].Day_Of_Week;
             sh.NumDem    = Building.Classes[i].NumDel;
             sh.Order_ID  = Building.Orders[j].ID_Order;
             sh.Room_ID   = Building.Classes[i].Room;
             using (db_schedule db = new db_schedule())
             {
                 Shedule shedule = db.Shedule
                                   .Where(s => s.DayOfWeek == sh.DayOfWeek && s.Couple_ID == sh.Couple_ID && s.NumDem == sh.NumDem && s.Room_ID == sh.Room_ID)
                                   .FirstOrDefault();
                 if (shedule == null)
                 {
                     AddShedule(sh);
                 }
                 else
                 {
                     UpdateShedule(sh);
                 }
                 db.SaveChanges();
             }
             //AddShedule(sh);
         }
     }
 }
Ejemplo n.º 2
0
 public Shedule AddShedule(Shedule shedule)
 {
     using (db_schedule db = new db_schedule())
     {
         db.Shedule.Add(shedule);
         db.SaveChanges();
         return(shedule);
     }
 }
Ejemplo n.º 3
0
 public Shedule FindByIDShedule(int id)
 {
     using (db_schedule db = new db_schedule())
     {
         Shedule shedule = db.Shedule
                           .Where(s => s.ID_Shedule == id)
                           .FirstOrDefault();
         db.SaveChanges();
         return(shedule);
     }
 }
Ejemplo n.º 4
0
 public void DeleteShedule(int id)
 {
     using (db_schedule db = new db_schedule())
     {
         Shedule shedule = db.Shedule
                           .Where(s => s.ID_Shedule == id)
                           .FirstOrDefault();
         db.Shedule.Remove(shedule);
         db.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public void UpdateShedule(Shedule shedule)
 {
     using (db_schedule db = new db_schedule())
     {
         Shedule sh = db.Shedule
                      .Where(s => s.ID_Shedule == shedule.ID_Shedule)
                      .FirstOrDefault();
         sh.Order_ID = shedule.Order_ID;
         db.SaveChanges();
     }
 }