Example #1
0
 protected override Content CreateContent(StudentExtendedProxy student, DisciplineExtendedProxy[] disciplines, GroupExtendedProxy group)
 {
     return(new Content(
                new FieldContent("FirstName", student.FirstName),
                new FieldContent("SecondName", student.SecondName),
                new FieldContent("ThirdName", student.ThirdName),
                new FieldContent("DateOfBirth", student.DateOfBirth.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU"))),
                new FieldContent("PreviousEducationName", student.PreviousEducationName),
                new FieldContent("PreviousEducationYear", student.PreviousEducationYear.ToString()),
                new FieldContent("EnrollmentYear", student.EnrollmentYear.ToString()),
                new FieldContent("EnrollmentName", student.EnrollmentName),
                new FieldContent("ExpulsionName", student.ExpulsionName),
                new FieldContent("ExpulsionYear", student.ExpulsionYear.ToString()),
                new FieldContent("ExpulsionOrderDate", student.ExpulsionOrderDate.ToString("dd.mm.yyyy")),
                new FieldContent("ExpulsionOrderNumber", student.ExpulsionOrderNumber.ToString()),
                new FieldContent("NormativePeriodOfStudy", (student.ExpulsionYear - student.EnrollmentYear).ToString()),
                new FieldContent("SpecialtyNumber", group.SpecialtyNumber.ToString()),
                new FieldContent("FacultyName", group.FacultyName),
                new FieldContent("SpecialtyName", group.SpecialtyName),
                CreateCourceWorksTable(student.AssessmentByDisciplines),
                CreateAssessmentByDisciplinesTable1(student.AssessmentByDisciplines, disciplines),
                CreateAssessmentByDisciplinesTable2(student.AssessmentByDisciplines, disciplines),
                CreateAssessmentByDisciplinesTable3(student.AssessmentByDisciplines),
                new FieldContent("SumTotalHours", disciplines.Sum(discipline => discipline.TotalHours).ToString()),
                new FieldContent("SumClassHours", disciplines.Sum(discipline => discipline.ClassHours).ToString())
                ));
 }
Example #2
0
        protected override Content CreateContent(StudentExtendedProxy student, DisciplineExtendedProxy[] disciplines, GroupExtendedProxy group)
        {
            var content = new Content(
                CreateCourceWorksTable(student.AssessmentByDisciplines),
                new FieldContent("FirstName", student.FirstName),
                new FieldContent("SecondName", student.SecondName),
                new FieldContent("ThirdName", student.ThirdName),
                new FieldContent("DateOfBirth", student.DateOfBirth.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU"))),
                new FieldContent("PreviousEducationName", student.PreviousEducationName),
                new FieldContent("PreviousEducationYear", student.PreviousEducationYear.ToString()),
                new FieldContent("SpecialtyNumber", group.SpecialtyNumber.ToString()),
                new FieldContent("FacultyName", group.FacultyName),
                new FieldContent("RegistrationNumber", student.RegistrationNumber),
                new FieldContent("ProtectionDate", student.ProtectionDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU"))),
                new FieldContent("NormativePeriodOfStudy", (student.ExpulsionYear - student.EnrollmentYear).ToString()),
                CreateAssessmentByDisciplinesTable1(student.AssessmentByDisciplines, disciplines),
                CreateAssessmentByDisciplinesTable2(student.AssessmentByDisciplines, disciplines),
                CreateAssessmentByDisciplinesTable3(student.AssessmentByDisciplines),
                new FieldContent("SumPracticeWeeks", disciplines.Where(discipline => discipline.ControlType == ControlType.Practice).Sum(discipline => discipline.ClassHours).ToString()),
                new FieldContent("DiplomaTopic", student.DiplomaTopic),
                new FieldContent("DiplomaAssessment", typeof(Assessment).GetField(student.DiplomaAssessment.ToString()).GetCustomAttribute <NameEnumValueAttribute>().NameEnumValue.ToLower()),
                new FieldContent("SumTotalWeeks", (disciplines.Sum(discipline => discipline.TotalHours) / 7).ToString()),
                new FieldContent("SumClassHours", disciplines.Sum(discipline => discipline.ClassHours).ToString())
                );

            return(content);
        }
        public void Edit(StudentExtendedProxy oldExtendedProxy, StudentExtendedProxy newExtendedProxy)
        {
            var foundStudent = ModelDatabase.GetStudent(oldExtendedProxy);

            foundStudent.FirstName             = newExtendedProxy.FirstName;
            foundStudent.SecondName            = newExtendedProxy.SecondName;
            foundStudent.ThirdName             = newExtendedProxy.ThirdName;
            foundStudent.DateOfBirth           = newExtendedProxy.DateOfBirth;
            foundStudent.PreviousEducationName = newExtendedProxy.PreviousEducationName;
            foundStudent.PreviousEducationYear = newExtendedProxy.PreviousEducationYear;
            foundStudent.EnrollmentName        = newExtendedProxy.EnrollmentName;
            foundStudent.EnrollmentYear        = newExtendedProxy.EnrollmentYear;
            foundStudent.ExpulsionName         = newExtendedProxy.ExpulsionName;
            foundStudent.ExpulsionYear         = newExtendedProxy.ExpulsionYear;
            foundStudent.ExpulsionOrderDate    = newExtendedProxy.ExpulsionOrderDate;
            foundStudent.ExpulsionOrderNumber  = newExtendedProxy.ExpulsionOrderNumber;
            foundStudent.DiplomaTopic          = newExtendedProxy.DiplomaTopic;
            foundStudent.DiplomaAssessment     = (int)newExtendedProxy.DiplomaAssessment;
            foundStudent.ProtectionDate        = newExtendedProxy.ProtectionDate;
            foundStudent.ProtocolNumber        = newExtendedProxy.ProtocolNumber;
            foundStudent.RegistrationNumber    = newExtendedProxy.RegistrationNumber;
            foundStudent.RegistrationDate      = newExtendedProxy.RegistrationDate;
            foundStudent.AssessmentByDisciplines.ForEach(assessmentByDiscipline =>
                                                         assessmentByDiscipline.Assessment = (int)newExtendedProxy.AssessmentByDisciplines.First(a =>
                                                                                                                                                 a.NameOfDiscipline == assessmentByDiscipline.Discipline.DisciplineName)
                                                                                             .Assessment);

            ModelDatabase.SaveChanges();
        }
        public void AddStudentFunctionTest_ShouldBeSuccess()
        {
            var student = new StudentExtendedProxy {
                FirstName = "firstName"
            };

            RunServer(new AddStudentFunction(DatabaseAuthorizer, databaseStudentEditor));
            SendRequest("AddStudent", GetDefaultParameters(), student.ToJson());

            A.CallTo(() => databaseStudentEditor.Add(student)).MustHaveHappened(Repeated.Exactly.Once);
        }
        public void EditStudentFunctionTest_ShouldBeSuccess()
        {
            var firstStudent = new StudentExtendedProxy {
                FirstName = "firstFirstName"
            };
            var secondStudent = new StudentExtendedProxy {
                FirstName = "secondFirstName"
            };

            RunServer(new EditStudentFunction(DatabaseAuthorizer, databaseStudentEditor));
            SendRequest("EditStudent", GetDefaultParameters(), Tuple.Create(firstStudent, secondStudent).ToJson());

            A.CallTo(() => databaseStudentEditor.Edit(firstStudent, secondStudent)).MustHaveHappened(Repeated.Exactly.Once);
        }
Example #6
0
        public void CreateDiplomaSupplementReportFunctionTest_ShouldBeSuccess()
        {
            var student = new StudentExtendedProxy {
                FirstName = "firstName"
            };
            var fileWithContent = new FileWithContent("TestName", null);

            A.CallTo(() => reportsCreator.CreateDiplomaSupplement(student)).Returns(fileWithContent);

            RunServer(new CreateDiplomaSupplementReportFunction(DatabaseAuthorizer, reportsCreator));
            var receivedFileWithContent = SendRequest <FileWithContent>("CreateDiplomaSupplementReport", GetDefaultParameters(), student.ToJson());

            A.CallTo(() => reportsCreator.CreateDiplomaSupplement(student)).MustHaveHappened(Repeated.Exactly.Once);
            Assert.That(receivedFileWithContent.FileName, Is.EqualTo(fileWithContent.FileName));
        }
Example #7
0
        public void GetExtendedStudentFunctionTest_ShouldBeSuccess()
        {
            var inputBasedStudent = new StudentBasedProxy {
                FirstName = "firstName"
            };
            var inputExtendedStudent = new StudentExtendedProxy {
                FirstName = "firstName"
            };

            A.CallTo(() => databaseStudentReader.GetExtendedProxy(inputBasedStudent)).Returns(inputExtendedStudent);

            RunServer(new GetExtendedStudentFunction(DatabaseAuthorizer, databaseStudentReader));
            var receivedStudent = SendRequest <StudentExtendedProxy>("GetExtendedStudent", GetDefaultParameters(), inputBasedStudent.ToJson());

            A.CallTo(() => databaseStudentReader.GetExtendedProxy(inputBasedStudent)).MustHaveHappened(Repeated.Exactly.Once);
            Assert.That(receivedStudent, Is.EqualTo(inputExtendedStudent));
        }
Example #8
0
        protected override Content CreateContent(StudentExtendedProxy student, DisciplineExtendedProxy[] disciplines, GroupExtendedProxy group)
        {
            var registrationDate = student.RegistrationDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU")).Split();

            return(new Content(
                       new FieldContent("RegistrationNumber", student.RegistrationNumber),
                       new FieldContent("ProtectionDate", student.ProtectionDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU"))),
                       new FieldContent("RegistrationNumber", student.RegistrationNumber),
                       new FieldContent("FirstName", student.FirstName),
                       new FieldContent("SecondName", student.SecondName),
                       new FieldContent("ThirdName", student.ThirdName),
                       new FieldContent("SpecialtyNumber", group.SpecialtyNumber.ToString()),
                       new FieldContent("FacultyName", group.FacultyName),
                       new FieldContent("ProtocolNumber", student.ProtocolNumber),
                       new FieldContent("RegistrationDateDay", registrationDate[0]),
                       new FieldContent("RegistrationDateMonth", registrationDate[1]),
                       new FieldContent("RegistrationDateYear", registrationDate[2])));
        }
        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();
        }
Example #10
0
 protected abstract Content CreateContent(StudentExtendedProxy student, DisciplineExtendedProxy[] disciplines, GroupExtendedProxy group);
 public void Edit(StudentExtendedProxy oldExtendedProxy, StudentExtendedProxy newExtendedProxy)
 {
     SendRequest("EditStudent", GetDefaultParameters(), Tuple.Create(oldExtendedProxy, newExtendedProxy).ToJson());
 }
 public void Add(StudentExtendedProxy extendedProxy)
 {
     SendRequest("AddStudent", GetDefaultParameters(), extendedProxy.ToJson());
 }