예제 #1
0
 private void AddSchedule(object s, RoutedEventArgs e)
 {
     NewSchedule.Time = DateTime.Now;
     scheduleDbContext.Schedules.Add(NewSchedule);
     scheduleDbContext.SaveChanges();
     GetProducts();
     NewSchedule = new Schedule();
     NewScheduleGrid.DataContext = NewSchedule;
 }
예제 #2
0
        public static void Initialize(ScheduleDbContext context)
        {
            //if (env.EnvironmentName == "Development")
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            // Look for any data
            if (context.ScheduleInfos.Any())
            {
                return; // DB has been seeded
            }

            var scheduleInfos = new ScheduleInfo[]
            {
                new ScheduleInfo {
                    InfoName = "info1", Schema = "SMART901"
                }
            };

            foreach (ScheduleInfo s in scheduleInfos)
            {
                context.ScheduleInfos.Add(s);
            }
            context.SaveChanges();
        }
예제 #3
0
        public ActionResult DoUpload(IFormFile file)
        {
            using (var stream = file.OpenReadStream())
            {
                var xs       = new XmlSerializer(typeof(Lessons));
                var lesssons = (Lessons)xs.Deserialize(stream);


                using (var db = new ScheduleDbContext())
                {
                    var dbs = new DbLessons()
                    {
                        Day   = lesssons.Day,
                        Class = lesssons.Class,
                    };
                    dbs.LessonDay = new Collection <DbLesson>();
                    foreach (var lesson in lesssons.LessonDay)
                    {
                        dbs.LessonDay.Add(new DbLesson()
                        {
                            Subject  = lesson.Subject,
                            Audience = lesson.Audience
                        });
                    }
                    db.Lessons.Add(dbs);
                    db.SaveChanges();
                }

                return(View(lesssons));
            }
        }
예제 #4
0
 public int SaveChanges()
 {
     _logger.Info("Saving changes to database");
     return _dbContext.SaveChanges();
 }
예제 #5
0
 public static void AddToDb(Teacher teacher)
 {
     db.Teachers.Add(teacher);
     db.SaveChanges();
 }
예제 #6
0
 public static void AddToDb(Subject subject)
 {
     db.Subjects.Add(subject);
     db.SaveChanges();
 }
예제 #7
0
 public static void AddToDb(GroupSubject groupSubject)
 {
     db.GroupSubjects.Add(groupSubject);
     db.SaveChanges();
 }
예제 #8
0
 public static void AddToDb(TeacherSubject teacherSubject)
 {
     db.TeacherSubjects.Add(teacherSubject);
     db.SaveChanges();
 }
예제 #9
0
 public static void AddToDb(Room room)
 {
     db.Rooms.Add(room);
     db.SaveChanges();
 }
예제 #10
0
 public static void AddToDb(Group group)
 {
     db.Groups.Add(group);
     db.SaveChanges();
 }