public void Edit(DisciplineExtendedProxy oldExtendedProxy, DisciplineExtendedProxy newExtendedProxy)
        {
            var foundDiscipline    = ModelDatabase.GetDiscipline(oldExtendedProxy);
            var newGroupDiscipline = ModelDatabase.GetGroup(newExtendedProxy.GroupName);

            foundDiscipline.DisciplineName = newExtendedProxy.DisciplineName;
            foundDiscipline.TotalHours     = newExtendedProxy.TotalHours;
            foundDiscipline.ClassHours     = newExtendedProxy.ClassHours;
            if (foundDiscipline.ControlType != newExtendedProxy.ControlType)
            {
                foreach (var assessmentByDiscipline in ModelDatabase.AssessmentByDisciplines.Where(a => a.DisciplineId == foundDiscipline.DisciplineId))
                {
                    assessmentByDiscipline.Assessment = (int)Assessment.None;
                }
                foundDiscipline.ControlType = newExtendedProxy.ControlType;
            }
            if (foundDiscipline.GroupId != newGroupDiscipline.GroupId)
            {
                DeleteAssessmentByDisciplines(assessmentByDiscipline => assessmentByDiscipline.DisciplineId == foundDiscipline.DisciplineId);
                ModelDatabase.AssessmentByDisciplines.AddRange(
                    newGroupDiscipline.Students.Select(student =>
                                                       new AssessmentByDiscipline {
                    Student    = student,
                    Discipline = foundDiscipline,
                    Group      = newGroupDiscipline,
                    Assessment = (int)Assessment.None
                }));
                foundDiscipline.Group = newGroupDiscipline;
            }

            ModelDatabase.SaveChanges();
        }
 public AssessmentByDiscipline[] GetAssessmentByDisciplinesFromGroupName(string groupName)
 {
     return(modelDatabase.GetGroup(groupName)
            .Disciplines.Select(
                discipline => new AssessmentByDiscipline {
         NameOfDiscipline = discipline.DisciplineName,
         ControlType = discipline.ControlType,
         Assessment = Assessment.None
     })
            .ToArray());
 }
Exemple #3
0
        public void Edit(GroupExtendedProxy oldExtendedProxy, GroupExtendedProxy newExtendedProxy)
        {
            var foundGroup = ModelDatabase.GetGroup(oldExtendedProxy);

            foundGroup.GroupName       = newExtendedProxy.GroupName;
            foundGroup.SpecialtyName   = newExtendedProxy.SpecialtyName;
            foundGroup.SpecialtyNumber = newExtendedProxy.SpecialtyNumber;
            foundGroup.FacultyName     = newExtendedProxy.FacultyName;

            ModelDatabase.SaveChanges();
        }
        public void Add(DisciplineExtendedProxy extendedProxy)
        {
            var foundGroup    = ModelDatabase.GetGroup(extendedProxy.GroupName);
            var newDiscipline = new Discipline {
                DisciplineName = extendedProxy.DisciplineName,
                ControlType    = extendedProxy.ControlType,
                TotalHours     = extendedProxy.TotalHours,
                ClassHours     = extendedProxy.ClassHours,
                Group          = foundGroup
            };

            ModelDatabase.Disciplines.Add(newDiscipline);
            ModelDatabase.AssessmentByDisciplines.AddRange(
                foundGroup.Students.Select(student =>
                                           new AssessmentByDiscipline {
                Student    = student,
                Discipline = newDiscipline,
                Group      = foundGroup,
                Assessment = (int)Assessment.None
            }));

            ModelDatabase.SaveChanges();
        }
        public void Add(StudentExtendedProxy extendedProxy)
        {
            var foundGroup = ModelDatabase.GetGroup(extendedProxy.GroupName);
            var newStudent = new Student {
                FirstName             = extendedProxy.FirstName,
                SecondName            = extendedProxy.SecondName,
                ThirdName             = extendedProxy.ThirdName,
                DateOfBirth           = extendedProxy.DateOfBirth,
                PreviousEducationName = extendedProxy.PreviousEducationName,
                PreviousEducationYear = extendedProxy.PreviousEducationYear,
                EnrollmentName        = extendedProxy.EnrollmentName,
                EnrollmentYear        = extendedProxy.EnrollmentYear,
                ExpulsionName         = extendedProxy.ExpulsionName,
                ExpulsionYear         = extendedProxy.ExpulsionYear,
                ExpulsionOrderDate    = extendedProxy.ExpulsionOrderDate,
                ExpulsionOrderNumber  = extendedProxy.ExpulsionOrderNumber,
                DiplomaTopic          = extendedProxy.DiplomaTopic,
                DiplomaAssessment     = (int)extendedProxy.DiplomaAssessment,
                ProtectionDate        = extendedProxy.ProtectionDate,
                ProtocolNumber        = extendedProxy.ProtocolNumber,
                RegistrationNumber    = extendedProxy.RegistrationNumber,
                RegistrationDate      = extendedProxy.RegistrationDate,
                Group = foundGroup
            };

            newStudent.AssessmentByDisciplines = newStudent.Group.Disciplines.Select(discipline =>
                                                                                     new AssessmentByDiscipline {
                Student    = newStudent,
                Discipline = discipline,
                Group      = foundGroup,
                Assessment = (int)extendedProxy.AssessmentByDisciplines.First(a => a.NameOfDiscipline == discipline.DisciplineName).Assessment
            })
                                                 .ToList();

            ModelDatabase.Students.Add(newStudent);
            ModelDatabase.SaveChanges();
        }
Exemple #6
0
 public GroupExtendedProxy GetExtendedProxy(GroupBasedProxy basedProxy)
 {
     return(modelDatabase.GetGroup(basedProxy).ToExtendedProxy());
 }
Exemple #7
0
 public void Delete(GroupBasedProxy basedProxy)
 {
     DeleteGroup(ModelDatabase.GetGroup(basedProxy));
     ModelDatabase.SaveChanges();
 }