using System; using System.Collections.Generic; using ReactiveUI; using TeacheresAndCourses.Models; namespace TeacheresAndCourses.ViewModels { internal class AddCourseViewModel : ViewModelBase { Course? newCourse; string courseTitle; int courseHours; public AddCourseViewModel() { newCourse = new Course(); } public Course NewCourse { get => newCourse; set => this.RaiseAndSetIfChanged(ref newCourse, value); } public string CourseTitle { get => courseTitle; set => this.RaiseAndSetIfChanged(ref courseTitle, value); } public int CourseHours { get => courseHours; set => this.RaiseAndSetIfChanged(ref courseHours, value); } public void AddCourse() { if (CourseTitle!=null && CourseHours!=null) { NewCourse.Title = CourseTitle + " - " + courseHours + " часов"; } MainWindowViewModel.connection.Courses.Add(NewCourse); MainWindowViewModel.connection.SaveChanges(); MainWindowViewModel.Instance.Uc = new AddTeacher(); } public void ToMainPage() { MainWindowViewModel.Instance.Uc = new TeachersPage(); } } }