private void AddToIndex(Lecturer lecturer, IndexWriter writer)
        {
            var searchQuery = new TermQuery(new Term(SearchingFields.Id.ToString(), lecturer.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            var doc = new Document();

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

            writer.AddDocument(doc);
        }
Example #2
0
 public static LecturerViewModel FormLecturers(Lecturer lecturer, string htmlLinks)
 {
     return new LecturerViewModel
       {
           Id = lecturer.Id,
           FirstName = lecturer.FirstName,
           LastName = lecturer.LastName,
           MiddleName = lecturer.MiddleName,
           Login = lecturer.User.UserName,
           HtmlLinks = new HtmlString(htmlLinks),
           LastLogin = lecturer.User.LastLogin.HasValue ? lecturer.User.LastLogin.ToString() : "-",
           Subjects = (lecturer.SubjectLecturers != null && lecturer.SubjectLecturers.Count > 0)
                         ? lecturer.SubjectLecturers.Count.ToString()
                         : "-",
       };
 }
 public Lecturer UpdateLecturer(Lecturer lecturer)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.LecturerRepository.Save(lecturer);
         var user = repositoriesContainer.UsersRepository.GetBy(new Query<User>(e => e.Id == lecturer.User.Id));
         user.Avatar = lecturer.User.Avatar;
         user.SkypeContact = lecturer.User.SkypeContact;
         user.Email = lecturer.User.Email;
         user.About = lecturer.User.About;
         user.Phone = lecturer.User.Phone;
         repositoriesContainer.UsersRepository.Save(user);
         repositoriesContainer.ApplyChanges();
     }
     new LecturerSearchMethod().UpdateIndex(lecturer);
     return lecturer;
 }
 public Lecturer Save(Lecturer lecturer)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.LecturerRepository.SaveLecturer(lecturer);
         repositoriesContainer.ApplyChanges();
     }
     return lecturer;
 }
 public void AddToIndex(Lecturer lecturer)
 {
     AddToIndex(new List<Lecturer> { lecturer });
 }
 public void UpdateIndex(Lecturer lecturer)
 {
     DeleteIndex(lecturer.Id);
     AddToIndex(lecturer);
 }