AddCourseVM.cs 753 B

123456789101112131415161718192021222324252627282930
  1. using ReactiveUI;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Teachers.Models;
  8. namespace Teachers.ViewModels
  9. {
  10. internal class AddCourseVM : ViewModelBase
  11. {
  12. Course? _newCourse;
  13. public Course? NewCourse { get => _newCourse; set => this.RaiseAndSetIfChanged(ref _newCourse, value); }
  14. public AddCourseVM()
  15. {
  16. _newCourse = new Course();
  17. }
  18. public void AddCourse()
  19. {
  20. MainWindowViewModel.myConnection.Courses.Add(NewCourse);
  21. MainWindowViewModel.myConnection.SaveChanges();
  22. MainWindowViewModel.Instance.PageContent = new OneTeacherV();
  23. }
  24. }
  25. }