1234567891011121314151617181920212223242526272829303132333435363738 |
- using AvaloniaBaseTeacher.Models;
- using Microsoft.EntityFrameworkCore;
- using ReactiveUI;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AvaloniaBaseTeacher.ViewModels
- {
- internal class AddCourseVM : ViewModelBase
- {
- Course _Newcourse;
- public Course Newcourse { get => _Newcourse; set => this.RaiseAndSetIfChanged(ref _Newcourse, value); }
- public AddCourseVM()
- {
- _Newcourse = new Course();
- }
- public AddCourseVM(int CourseId)
- {
- _Newcourse = MainWindowViewModel.myConnection.Courses.FirstOrDefault(x => x.IdCourse == CourseId);
- }
- public void AddCourse()
- {
- if(Newcourse.IdCourse == 0)
- {
- MainWindowViewModel.myConnection.Courses.Add(Newcourse);
- }
- MainWindowViewModel.myConnection.SaveChanges();
- MainWindowViewModel.Instance.PageContent = new Add();
- }
-
- }
- }
|