Exemplo n.º 1
0
 public void Save(Student student)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.StudentsRepository.SaveStudent(student);
         repositoriesContainer.ApplyChanges();
     }
 }
 public static TestResultItemListViewModel FromStudent(Student student)
 {
     return new TestResultItemListViewModel
     {
         StudentName = student.FullName,
         StudentShortName = GetShortStudentName(student),
         TestPassResults = student.User.TestPassResults.ToArray()
     };
 }
Exemplo n.º 3
0
        public void UpdateStudent(Student student)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                repositoriesContainer.StudentsRepository.Save(student);
	            var user = repositoriesContainer.UsersRepository.GetBy(new Query<User>(e => e.Id == student.User.Id));
	            user.UserName = student.User.UserName;
	            user.Avatar = student.User.Avatar;
				repositoriesContainer.UsersRepository.Save(user);
                repositoriesContainer.ApplyChanges();
            }
        }
Exemplo n.º 4
0
 public static StudentViewModel FromStudent(Student student, string htmlLinks)
 {
     return new StudentViewModel
       {
     Id = student.Id,
     FirstName = student.FirstName,
     LastName = student.LastName,
     MiddleName = student.MiddleName,
     Group = student.Group.Name,
     Login = student.User.UserName,
     HtmlLinks = new HtmlString(htmlLinks),
     LastLogin = student.User.LastLogin.HasValue ? student.User.LastLogin.ToString() : "-"
       };
 }
        private void AddToIndex(Student student, IndexWriter writer)
        {
            var searchQuery = new TermQuery(new Term(SearchingFields.Id.ToString(), student.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            var doc = new Document();
            
            doc.Add(new Field(SearchingFields.Id.ToString(), student.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));            
            doc.Add(new Field(SearchingFields.FirstName.ToString(), student.FirstName, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field(SearchingFields.MiddleName.ToString(), student.MiddleName, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field(SearchingFields.LastName.ToString(), student.LastName, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field(SearchingFields.Group.ToString(), student.Group != null ? student.Group.Name : "", Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field(SearchingFields.Name.ToString(), student.User != null ? student.User.UserName : "", Field.Store.YES, Field.Index.ANALYZED));

            writer.AddDocument(doc);
        }
 public PracticalVisitingMarkViewData(Student student, int scheduleId)
 {
     ScheduleProtectionPracticalId = scheduleId;
     StudentId = student.Id;
     StudentName = student.FullName;
     if (student.ScheduleProtectionPracticalMarks.Any(e => e.ScheduleProtectionPracticalId == scheduleId))
     {
         Comment =
             student.ScheduleProtectionPracticalMarks.FirstOrDefault(e => e.ScheduleProtectionPracticalId == scheduleId)
                 .Comment;
         Mark =
             student.ScheduleProtectionPracticalMarks.FirstOrDefault(e => e.ScheduleProtectionPracticalId == scheduleId).Mark;
         PracticalVisitingMarkId = student.ScheduleProtectionPracticalMarks.FirstOrDefault(e => e.ScheduleProtectionPracticalId == scheduleId).Id;
     }
     else
     {
         Comment = string.Empty;
         Mark = string.Empty;
         PracticalVisitingMarkId = 0;
     }
 }
Exemplo n.º 7
0
        public ModifyStudentViewModel(Student student)
        {
            if (student != null)
            {
                if (student.GroupId == 0)
                {
                    Group = StudentManagementService.GetStudent(student.Id).GroupId.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    Group = student.GroupId.ToString(CultureInfo.InvariantCulture);
                }

                Id = student.Id;
                Name = student.FirstName;
                Surname = student.LastName;
                Patronymic = student.MiddleName;
                Email = student.Email;
                UserName = student.User.UserName;
                Avatar = student.User.Avatar;
            }
        }
Exemplo n.º 8
0
        public UserInfoViewModel(int _id)
        {
            var context = new LmPlatformModelsContext();
            var id = context.ProjectUsers.Find(_id).UserId;

            if (context.Students.Find(id) != null)
            {
                //var creator = context.Students.Find(id);
                var creator = new Student();
                foreach (var student in context.Students)
                {
                    if (student.Id == id)
                    {
                        creator = student;
                    }
                }

                UserName = creator.LastName + " " + creator.FirstName + " " + creator.MiddleName;
                GroupNumber = context.Groups.Find(creator.GroupId).Name;
                ProjectQuentity = context.ProjectUsers.Select(e => e.User).Count(e => e.Id == creator.Id);
                Role = "Студент";
            }
            else
            {
                var creator = context.Lecturers.Find(id);
                UserName = creator.LastName + " " + creator.FirstName + " " + creator.MiddleName;
                ProjectQuentity = context.ProjectUsers.Select(e => e.User).Count(e => e.Id == creator.Id);
                Role = "Преподаватель";

                var _context = new SubjectManagementService();
                SubjectList = new List<Subject>();
                foreach (var subject in _context.GetUserSubjects(creator.Id))
                {
                    SubjectList.Add(subject);
                }
            }
        }
Exemplo n.º 9
0
        private int? GetPoints(Student rawStudent, int testId)
        {
            var passResult = rawStudent.User.TestPassResults.Where(result => result.TestId == testId);
            if (passResult.Count() == 1)
            {
                return passResult.Single().Points;
            }

            if (passResult.Count() > 1)
            {
                return passResult.Sum(result => result.Points);
            }

            return null;
        }
Exemplo n.º 10
0
        private List<TestPassResult> GetTestPassResultsForStudent(int[] testIds, Student rawStudent)
        {
            var tests = GetTests();
            var testPassResults = new List<TestPassResult>();
            foreach (int testId in testIds)
            {
                var t = tests.SingleOrDefault(test => test.Id == testId);
                testPassResults.Add(new TestPassResult
                {
                    TestId = testId,
                    TestName = t != null ? t.Title : "Тест", 
                    Points = GetPoints(rawStudent, testId)
                });
            }

            return testPassResults;
        }
Exemplo n.º 11
0
 private static string GetShortStudentName(Student student)
 {
     return student.LastName + ' ' + student.FirstName[0] + '.';
 }
 public void AddToIndex(Student student)
 {
     AddToIndex(new List<Student> {student});
 }
 public void UpdateIndex(Student student)
 {
     DeleteIndex(student.Id);
     AddToIndex(student);
 }