private void AddSchedule(object s, RoutedEventArgs e) { NewSchedule.Time = DateTime.Now; scheduleDbContext.Schedules.Add(NewSchedule); scheduleDbContext.SaveChanges(); GetProducts(); NewSchedule = new Schedule(); NewScheduleGrid.DataContext = NewSchedule; }
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(); }
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)); } }
public int SaveChanges() { _logger.Info("Saving changes to database"); return _dbContext.SaveChanges(); }
public static void AddToDb(Teacher teacher) { db.Teachers.Add(teacher); db.SaveChanges(); }
public static void AddToDb(Subject subject) { db.Subjects.Add(subject); db.SaveChanges(); }
public static void AddToDb(GroupSubject groupSubject) { db.GroupSubjects.Add(groupSubject); db.SaveChanges(); }
public static void AddToDb(TeacherSubject teacherSubject) { db.TeacherSubjects.Add(teacherSubject); db.SaveChanges(); }
public static void AddToDb(Room room) { db.Rooms.Add(room); db.SaveChanges(); }
public static void AddToDb(Group group) { db.Groups.Add(group); db.SaveChanges(); }