1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using AvaloniaApplication4.AdditionalModels;
- using AvaloniaApplication4.Models;
- using AvaloniaApplication4.Views.ActionPages;
- using Microsoft.EntityFrameworkCore;
- using ReactiveUI;
- namespace AvaloniaApplication4.ViewModels
- {
- public class AllSubjectsModulesAndProgramTemplatesViewModel : ViewModelBase
- {
- GlobalsData globalsData;
- User? user;
- List<Subject> subjects;
- List<Models.Module> modules;
- List<ProgramTemplate> programTemplates;
- public AllSubjectsModulesAndProgramTemplatesViewModel(GlobalsData globalsData, User? user)
- {
- this.globalsData = globalsData;
- this.user = user;
- subjects = dataBase.Subjects.Include(x => x.IdCodeAcademicSubjectNavigation).Include(x => x.IdTrainingStandartsNavigation).ToList();
- modules = dataBase.Modules.ToList();
- programTemplates = dataBase.ProgramTemplates.ToList();
- }
- public List<Subject> Subjects { get => subjects; set => subjects = value; }
- public List<Models.Module> Modules { get => modules; set => modules = value; }
- public List<ProgramTemplate> ProgramTemplates { get => programTemplates; set => programTemplates = value; }
- public void AddNewSubject()
- {
- globalsData.GlobalUserControl = new EditAndAddSubject(user, ref globalsData);
- }
- public void AddNewModule()
- {
- globalsData.GlobalUserControl = new EditAndAddModule(user, ref globalsData);
- }
- public void AddNewProgramTemplate()
- {
- globalsData.GlobalUserControl = new EditAndAddProgramTemplate(user, ref globalsData);
- }
- public void EditSubject(int idSubject)
- {
- var subject = dataBase.Subjects.FirstOrDefault(x => x.IdSubject == idSubject);
- if (subject != null)
- {
- globalsData.GlobalUserControl = new EditAndAddSubject(user, ref globalsData, subject);
- }
- }
- public void EditModule(int idModule)
- {
- var module = dataBase.Modules.FirstOrDefault(x=>x.IdModule == idModule);
- if (module != null)
- {
- globalsData.GlobalUserControl = new EditAndAddModule(user, ref globalsData,module);
- }
- }
- public void EditProgramTemplate(int idProgramTemplate)
- {
- var programTemplate = dataBase.ProgramTemplates.FirstOrDefault(x => x.IdProgramTemplate == idProgramTemplate);
- if (programTemplate != null)
- {
- globalsData.GlobalUserControl = new EditAndAddProgramTemplate(user, ref globalsData, programTemplate);
- }
- }
- }
- }
|