Exemplo n.º 1
0
 public StudentMaterialViewModel(StudentEducationMaterial material)
 {
     _true     = new SolidColorBrush(Colors.LimeGreen);
     _false    = new SolidColorBrush(Colors.Red);
     _material = material;
     Parts     = new ObservableCollection <StudentMaterialPartViewModel>(material.PartsInfo.Select(i => new StudentMaterialPartViewModel(i, _true, _false)));
 }
Exemplo n.º 2
0
        public void Insert(StudentEducationMaterial educationMaterial)
        {
            var materials = _studentEducationMaterailsProvider.Select();

            if (materials.Any(i => i.Theme == educationMaterial.Theme && i.Student.Equals(educationMaterial.Student)))
            {
                _studentEducationMaterailsProvider.Update(educationMaterial);
            }
            else
            {
                _studentEducationMaterailsProvider.Create(educationMaterial);
            }
        }
Exemplo n.º 3
0
 public MaterialDetailsWindowViewModel(StudentEducationMaterial educationMaterial, IEducationMaterialsManager materialsManager)
 {
     Theme = educationMaterial.Theme;
     Parts = new ObservableCollection <MaterialPartViewModel>(educationMaterial.PartsInfo.Select(i => new MaterialPartViewModel {
         Theme = i.Key.Theme, Content = i.Key.Content, IsReaded = i.Value
     }));
     _sessionCount = educationMaterial.SessionsCount + 1;
     Close         = new DelegateCommand(() => {
         var parts = new List <SerializableKeyValuePair <EducationMaterialPart, bool> >();
         foreach (var part in Parts)
         {
             var origin = educationMaterial.Parts.FirstOrDefault(i => i.Theme == part.Theme);
             parts.Add(new SerializableKeyValuePair <EducationMaterialPart, bool>(origin, part.IsReaded));
         }
         var result = new StudentEducationMaterial(educationMaterial.Student, educationMaterial.Owner, educationMaterial.Theme, _sessionCount, parts);
         materialsManager.Insert(result);
         if (ViewService.GetIfOpened(out var view, this))
         {
             view.Close();
         }
     });
 }
Exemplo n.º 4
0
 public MaterialDetailsWindowViewModel MaterialDetailsWindowViewModel(StudentEducationMaterial material) => new MaterialDetailsWindowViewModel(material, _educationMaterialsManager);