Example #1
0
 public List<BugLog> GetBugLogs(int bugId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.BugLogsRepository.GetAll(new Query<BugLog>(e => e.BugId == bugId).Include(e => e.User)).ToList();
     }
 }
Example #2
0
 public ActionResult GetObjects()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return Json(repositoriesContainer.RepositoryFor<ScoObjects>().GetAll(new Query<ScoObjects>(e => !e.IsDeleted)).ToList(), JsonRequestBehavior.AllowGet);
     }
 }
 public List<Lecturer> GetLecturers()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.LecturerRepository.GetAll(new Query<Lecturer>().Include(e => e.SubjectLecturers).Include(e => e.User)).ToList();
     }
 }
        public void DeleteLabs(int id)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var labs =
                    repositoriesContainer.LabsRepository.GetBy(
                        new Query<Labs>(e => e.Id == id).Include(e => e.StudentLabMarks));

                var deleteFiles =
                        repositoriesContainer.AttachmentRepository.GetAll(
                            new Query<Attachment>(e => e.PathName == labs.Attachments)).ToList();

                var studentLabMarks =
                    repositoriesContainer.RepositoryFor<StudentLabMark>()
                        .GetAll(new Query<StudentLabMark>(e => e.LabId == id))
                        .ToList();

                foreach (var attachment in deleteFiles)
                {
                    FilesManagementService.DeleteFileAttachment(attachment);
                }

                foreach (var mark in studentLabMarks)
                {
                    repositoriesContainer.RepositoryFor<StudentLabMark>().Delete(mark);
                }

                repositoriesContainer.ApplyChanges();

                repositoriesContainer.LabsRepository.Delete(labs);

                repositoriesContainer.ApplyChanges();
            }
        }
 public Group GetGroup(int groupId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.GroupsRepository.GetBy(new Query<Group>(e => e.Id == groupId).Include(e => e.Students.Select(x => x.LecturesVisitMarks)));
     }
 }
 public ProjectUser GetProjectUser(int projectUserId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ProjectUsersRepository.GetBy(new Query<ProjectUser>(e => e.Id == projectUserId).Include(e => e.Project).Include(e => e.User).Include(e => e.ProjectRole));
     }
 }
 public Student GetStudent(int userId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.StudentsRepository.GetBy(new Query<Student>(e => e.Id == userId).Include(e => e.Group).Include(e => e.User));
     }
 }
 public IEnumerable<Concept> GetRootElements(Int32 authorId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ConceptRepository.GetRootElementsByAuthorId(authorId);
     }
 }
 public Concept GetById(int id)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ConceptRepository.GetById(id);
     }
 }
 public IEnumerable<Student> GetStudents()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.StudentsRepository.GetAll(new Query<Student>().Include(e => e.Group).Include(e => e.User)).ToList();
     }
 }
 public IEnumerable<Concept> GetRootElementsBySubject(int subjectId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ConceptRepository.GetRootElementsBySubjectId(subjectId);
     }
 }
		public List<Subject> GetGroupSubjects(int groupId)
		{
			using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
			{
				return repositoriesContainer.SubjectRepository.GetSubjects(groupId: groupId).Where(e => !e.IsArchive).ToList();
			}
		}
 public ICollection<Module> GetModules()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ModulesRepository.GetAll().ToList();
     }
 }
 public List<Group> GetGroups(IQuery<Group> query = null)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.GroupsRepository.GetAll(query).ToList();
     }
 }
 public string GetFileDisplayName(string guid)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.AttachmentRepository.GetBy(new Query<Attachment>(e => e.FileName == guid)).Name;
     }
 }
Example #16
0
 public List<Bug> GetBugs()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.BugsRepository.GetAll().ToList();
     }
 }
        public User GetUserByName(string firstName, string lastName, string middleName)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var checkPatronymic = !string.IsNullOrEmpty(middleName);

                var lecturers = repositoriesContainer.LecturerRepository.GetAll(
                        new Query<Lecturer>(e =>
                            (e.FirstName == firstName && e.LastName == lastName && !checkPatronymic)
                            || (checkPatronymic && (e.MiddleName == middleName && e.FirstName == firstName && e.LastName == lastName))))
                            .Select(l => l.User).ToList();

                if (lecturers.Any())
                {
                    return lecturers.First();
                }

                var students = repositoriesContainer.StudentsRepository.GetAll(
                        new Query<Student>(e =>
                            (e.FirstName == firstName && e.LastName == lastName && !checkPatronymic)
                            || (checkPatronymic && (e.MiddleName == middleName && e.FirstName == firstName && e.LastName == lastName))))
                            .Select(l => l.User);

                return students.Any() ? students.First() : null;
            }
        }
Example #18
0
 public Bug GetBug(int bugId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.BugsRepository.GetBy(new Query<Bug>(e => e.Id == bugId));
     }
 }
Example #19
0
        private int GetRemainingTime(int testId, int questionId, int userId)
        {
            var test = GetTest(testId);
            TestPassResult testPassResult = GetTestPassResult(testId, userId);

            double seconds = 0;

            if (test.SetTimeForAllTest)
            {
                seconds = (test.TimeForCompleting * 60) - (DateTime.UtcNow - testPassResult.StartTime).TotalSeconds;
            }
            else
            {
                if (testPassResult.Comment == questionId.ToString())
                {
                    seconds = test.TimeForCompleting - ((DateTime.UtcNow.Ticks - testPassResult.StartTime.Ticks) / TimeSpan.TicksPerSecond);
                }
                else
                {
                    seconds = test.TimeForCompleting;
                    testPassResult.StartTime = DateTime.UtcNow;
                    testPassResult.Comment = questionId.ToString();
                }

                using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
                {
                    repositoriesContainer.RepositoryFor<TestPassResult>().Save(testPassResult);
                    repositoriesContainer.ApplyChanges();
                }
            }

            return seconds > 0 ? (int)seconds : 0;
        }
        public Question SaveQuestion(Question question)
        {
            CheckForTestIsNotLocked(question.TestId);

            ValidateQuestion(question);

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                repositoriesContainer.QuestionsRepository.Save(question);
                Question existingQuestion = GetQuestion(question.Id);
                var answersToDelete = existingQuestion.Answers.Where(a => question.Answers.All(answer => answer.Id != a.Id));

                // TODO: Resolve problem (items are saved only first time)
                foreach (Answer answer in question.Answers)
                {
                    answer.QuestionId = question.Id;
                }

                repositoriesContainer.RepositoryFor<Answer>().Save(question.Answers);
                repositoriesContainer.RepositoryFor<Answer>().Delete(answersToDelete);

                repositoriesContainer.ApplyChanges();
                return question;
            }
        }
 public List<ProjectUser> GetProjectsOfUser(int userId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.ProjectUsersRepository.GetAll(new Query<ProjectUser>(e => e.UserId == userId).Include(e => e.Project).Include(e => e.User).Include(e => e.ProjectRole)).ToList();
     }
 }
 public List<Folders> GetAllFolders()
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         var currentUser = repositoriesContainer.FoldersRepository.GetAll(new Query<Folders>(u => u.Pid == 0)).ToList();
         return currentUser;
     }
 }
 public void Save(Student student)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.StudentsRepository.SaveStudent(student);
         repositoriesContainer.ApplyChanges();
     }
 }
 public Folders FolderRootBySubjectModuleId(int submodid)
 {
      using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         var currentUser = repositoriesContainer.FoldersRepository.FolderRootBySubjectModuleId(submodid);
         return currentUser;
     }
 }
 public Question GetQuestion(int id)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return repositoriesContainer.QuestionsRepository.GetBy(new Query<Question>(question => question.Id == id)
             .Include(question => question.Answers));
     }
 }
 public IList<Attachment> GetAttachments(string path)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return string.IsNullOrEmpty(path) ? repositoriesContainer.AttachmentRepository.GetAll().ToList() 
             : repositoriesContainer.AttachmentRepository.GetAll(new Query<Attachment>(e => e.PathName == path)).ToList();
     }
 }
        public Materials GetTextById(int id)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                Materials materials = repositoriesContainer.MaterialsRepository.GetDocumentById(id);

                return materials;
            }
        }
 public List<ProjectComment> GetProjectComments(int projectId)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         return
             repositoriesContainer.ProjectCommentsRepository.GetAll(new Query<ProjectComment>(e => e.ProjectId == projectId).Include(e => e.User))
                 .ToList();
     }
 }
 public void DeleteGroup(int id)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         var group = repositoriesContainer.GroupsRepository.GetBy(new Query<Group>().AddFilterClause(g => g.Id == id));
         repositoriesContainer.GroupsRepository.Delete(group);
         repositoriesContainer.ApplyChanges();
     }
 }
        public IEnumerable<User> GetMessageRecipients(int messageId)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var recipients = repositoriesContainer.MessageRepository.GetMessageRecipients(messageId).ToList();

                return recipients;
            }
        }
Example #31
0
        private void InitBaseChildrens(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            var concept1 = new Concept(TitlePageSectionName, parent.Author, parent.Subject, false, false)
            {
                ParentId = parent.Id, ReadOnly = true
            };

            repositoriesContainer.ConceptRepository.Save(concept1);

            var concept2 = new Concept(ProgramSectionName, parent.Author, parent.Subject, false, false)
            {
                ParentId = parent.Id, ReadOnly = true
            };

            repositoriesContainer.ConceptRepository.Save(concept2);

            concept1.NextConcept = concept2.Id;
            concept2.PrevConcept = concept1.Id;

            var concept3 = new Concept(LectSectionName, parent.Author, parent.Subject, true, false)
            {
                ParentId = parent.Id, ReadOnly = true
            };

            repositoriesContainer.ConceptRepository.Save(concept3);
            InitLectChild(concept3, repositoriesContainer);

            concept2.NextConcept = concept3.Id;
            concept3.PrevConcept = concept2.Id;

            var concept4 = new Concept(LabSectionName, parent.Author, parent.Subject, true, false)
            {
                ParentId = parent.Id, ReadOnly = true
            };

            repositoriesContainer.ConceptRepository.Save(concept4);
            InitPractChild(concept4, repositoriesContainer);

            concept3.NextConcept = concept4.Id;
            concept4.PrevConcept = concept3.Id;

            var concept5 = new Concept(TestSectionName, parent.Author, parent.Subject, true, true)
            {
                ParentId = parent.Id, ReadOnly = true
            };

            repositoriesContainer.ConceptRepository.Save(concept5);

            concept5.PrevConcept = concept4.Id;
            concept4.NextConcept = concept5.Id;
            repositoriesContainer.ApplyChanges();
        }
        public void SaveTinCanObject(string name, string guid)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();

            repositoriesContainer.RepositoryFor <TinCanObjects>().Save(new TinCanObjects()
            {
                Name      = name,
                Path      = guid,
                Enabled   = false,
                IsDeleted = false
            });
            repositoriesContainer.ApplyChanges();
        }
        public void DeleteBug(int bugId)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var bug =
                    repositoriesContainer.BugsRepository.GetBy(
                        new Query <Bug>().AddFilterClause(u => u.Id == bugId));
                repositoriesContainer.BugsRepository.DeleteBug(bug);
                repositoriesContainer.ApplyChanges();
            }

            ClearBugLogs(bugId);
        }
        public List <Subject> GetSubjectsByStudent(int userId)
        {
            List <Subject> model;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var student = repositoriesContainer.StudentsRepository.GetStudent(userId);
                model = repositoriesContainer.SubjectRepository.GetSubjects(student.GroupId).Where(e => !e.IsArchive)
                        .ToList();
            }

            return(model);
        }
Example #35
0
        public Test GetTest(int id, bool includeQuestions = false)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Test>(test => test.Id == id);
                if (includeQuestions)
                {
                    query.Include(t => t.Questions);
                }

                return(repositoriesContainer.TestsRepository.GetBy(query));
            }
        }
Example #36
0
        public int LabsCountByLector(int userId)
        {
            var count = 0;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var subjects = repositoriesContainer.SubjectRepository.GetSubjects(lecturerId: userId).Where(e => !e.IsArchive).ToList();

                count += subjects.Sum(subject => subject.Labs.Count);
            }

            return(count);
        }
 public Subject GetSubject(int id)
 {
     using var repositoriesContainer = new LmPlatformRepositoriesContainer();
     return(repositoriesContainer.SubjectRepository.GetBy(new Query <Subject>(e => e.Id == id)
                                                          .Include(e => e.SubjectModules.Select(x => x.Module))
                                                          .Include(e => e.SubjectNewses)
                                                          .Include(e => e.Lectures)
                                                          .Include(e => e.Labs)
                                                          .Include(e => e.SubjectLecturers.Select(x => x.Lecturer.User))
                                                          .Include(e => e.Practicals)
                                                          .Include(e => e.LecturesScheduleVisitings)
                                                          .Include(e => e.SubjectGroups.Select(x => x.SubGroups.Select(v => v.ScheduleProtectionLabs)))));
 }
Example #38
0
        public IEnumerable <Concept> GetRootElements(Int32 authorId, Boolean onlyVisible = false)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var rootElements = repositoriesContainer.ConceptRepository.GetRootElementsByAuthorId(authorId);
                if (!onlyVisible)
                {
                    return(rootElements);
                }

                return(rootElements.Where(re => ModulesManagementService.GetModules(re.SubjectId).Any(m => m.ModuleType == ModuleType.ComplexMaterial)));
            }
        }
        public List <UserLabFiles> GetUserLabFiles(int userId, int subjectId)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();

            if (userId == 0)
            {
                return(repositoriesContainer.RepositoryFor <UserLabFiles>()
                       .GetAll(new Query <UserLabFiles>(e => e.SubjectId == subjectId)).ToList());
            }

            return(repositoriesContainer.RepositoryFor <UserLabFiles>()
                   .GetAll(new Query <UserLabFiles>(e => e.UserId == userId && e.SubjectId == subjectId)).ToList());
        }
Example #40
0
        public void DeleteQuestion(int id)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                Question questionToDelete = repositoriesContainer.QuestionsRepository.GetBy(
                    new Query <Question>(question => question.Id == id));

                CheckForTestIsNotLocked(questionToDelete.TestId);

                repositoriesContainer.QuestionsRepository.Delete(questionToDelete);
                repositoriesContainer.ApplyChanges();
            }
        }
Example #41
0
        public void Remove(int id, bool removeChildren)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();
            var item     = GetById(id);
            var prev     = item.PrevConcept;
            var next     = item.NextConcept;
            var parentId = item.ParentId;

            repositoriesContainer.ConceptRepository.Remove(id, removeChildren);
            repositoriesContainer.ApplyChanges();
            ResetSiblings(prev, next, repositoriesContainer);
            TryPublishParent(parentId, repositoriesContainer);
        }
Example #42
0
        private AnswerOnTestQuestion GetAnswerOntestQuestion(int userId, int testId, int questionNumber)
        {
            AnswerOnTestQuestion answerOnTestQuestion;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                answerOnTestQuestion =
                    repositoriesContainer.RepositoryFor <AnswerOnTestQuestion>().GetBy(
                        new Query <AnswerOnTestQuestion>(answer => answer.UserId == userId && answer.TestId == testId && answer.Number == questionNumber));
            }

            return(answerOnTestQuestion);
        }
        public Test SaveTest(Test test, bool withountValidation = false)
        {
            if (!withountValidation)
            {
                CheckForTestIsNotLocked(test.Id);
                ValidateTest(test);
            }

            using var repositoriesContainer = new LmPlatformRepositoriesContainer();
            repositoriesContainer.TestsRepository.Save(test);
            repositoriesContainer.ApplyChanges();
            return(test);
        }
Example #44
0
        private TestPassResult GetTestPassResult(int testId, int userId)
        {
            TestPassResult result;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                result =
                    repositoriesContainer.RepositoryFor <TestPassResult>().GetBy(
                        new Query <TestPassResult>(res => res.TestId == testId && res.StudentId == userId));
            }

            return(result);
        }
Example #45
0
        private Answer GetAnswerById(int id)
        {
            Answer answerResult;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                answerResult =
                    repositoriesContainer.RepositoryFor <Answer>().GetBy(
                        new Query <Answer>(answer => answer.Id == id));
            }

            return(answerResult);
        }
        public void DeleteProject(int projectId)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var project =
                    repositoriesContainer.ProjectsRepository.GetBy(
                        new Query <Project>().AddFilterClause(u => u.Id == projectId));
                repositoriesContainer.ProjectsRepository.DeleteProject(project);
                repositoriesContainer.ApplyChanges();
            }

            new ProjectSearchMethod().DeleteIndex(projectId);
        }
Example #47
0
 public void SaveScheduleProtectionLabsDate(int subGroupId, DateTime date)
 {
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.RepositoryFor <ScheduleProtectionLabs>().Save(new ScheduleProtectionLabs
         {
             SuGroupId = subGroupId,
             Date      = date,
             Id        = 0
         });
         repositoriesContainer.ApplyChanges();
     }
 }
 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();
         new StudentSearchMethod().UpdateIndex(student);
     }
 }
Example #49
0
        public decimal GetSubjectCompleting(int subjectId)
        {
            decimal count = 0;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var subject =
                    repositoriesContainer.SubjectRepository.GetBy(
                        new Query <Subject>(e => e.Id == subjectId).Include(x => x.SubjectGroups.Select(t => t.SubGroups.Select(c => c.ScheduleProtectionLabs))));

                var dates = new List <DateTime>();

                var isDate = false;

                foreach (var subjectGroup in subject.SubjectGroups)
                {
                    foreach (var subGroup in subjectGroup.SubGroups)
                    {
                        if (subGroup.ScheduleProtectionLabs != null)
                        {
                            foreach (var scheduleProtectionLabs in subGroup.ScheduleProtectionLabs)
                            {
                                isDate = true;
                                dates.Add(scheduleProtectionLabs.Date);
                            }
                        }
                    }
                }

                if (isDate)
                {
                    var numberDates = dates.Count;
                    dates.Sort((a, b) => a.CompareTo(b));
                    var nowDate = DateTime.Now.Date;

                    var countDone = 0;

                    foreach (var dateTime in dates)
                    {
                        if (nowDate > dateTime)
                        {
                            countDone += 1;
                        }
                    }

                    count = Math.Round(((decimal)countDone / numberDates) * 100, 0);
                }
            }

            return(count);
        }
Example #50
0
        private void StartNewTest(int testId, int userId)
        {
            var test = GetTest(testId);

            var questionsCount = test.CountOfQuestions > test.Questions.Count
                                ? test.Questions.Count
                                : test.CountOfQuestions;
            IEnumerable <Question> includedQuestions = null;

            if (test.ForNN)
            {
                includedQuestions = test.Questions.OrderBy(t => t.ConceptId).ThenBy(a => a.Id).ToList();
            }
            else
            {
                var random = new Random(DateTime.Now.Millisecond);
                includedQuestions = test.Questions.OrderBy(t => random.Next()).Take(questionsCount);
            }

            var answersTemplate = new List <AnswerOnTestQuestion>();

            var counter = 1;

            foreach (var includedQuestion in includedQuestions)
            {
                answersTemplate.Add(new AnswerOnTestQuestion
                {
                    QuestionId = includedQuestion.Id,
                    TestId     = testId,
                    UserId     = userId,
                    Number     = counter++
                });
            }

            var testPassResult = GetTestPassResult(testId, userId) ?? new TestPassResult
            {
                TestId    = testId,
                StudentId = userId
            };

            testPassResult.StartTime = DateTime.UtcNow;

            using var repositoriesContainer = new LmPlatformRepositoriesContainer();
            var toDelete = repositoriesContainer.RepositoryFor <AnswerOnTestQuestion>()
                           .GetAll(new Query <AnswerOnTestQuestion>(x => x.TestId == testId && x.UserId == userId));

            repositoriesContainer.RepositoryFor <AnswerOnTestQuestion>().Delete(toDelete);
            repositoriesContainer.RepositoryFor <AnswerOnTestQuestion>().Save(answersTemplate);
            repositoriesContainer.RepositoryFor <TestPassResult>().Save(testPassResult);
            repositoriesContainer.ApplyChanges();
        }
Example #51
0
        public IEnumerable <Test> GetTestForLector(int currentUserId)
        {
            IEnumerable <Test> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Test>();
                query.AddFilterClause(test => test.Subject.SubjectLecturers.Any(sl => sl.LecturerId == currentUserId));

                searchResults = repositoriesContainer.TestsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
        public List <Subject> GetUserSubjects(int userId)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();

            var user = repositoriesContainer.UsersRepository.GetBy(new Query <User>(e => e.Id == userId)
                                                                   .Include(e => e.Lecturer)
                                                                   .Include(e => e.Student));

            if (user.Student != null)
            {
                return(repositoriesContainer.SubjectRepository.GetSubjects(user.Student.GroupId));
            }
            return(repositoriesContainer.SubjectRepository.GetSubjects(lecturerId: user.Lecturer.Id));
        }
Example #53
0
        public List <string> GetLecturesScheduleVisitings(int subjectId)
        {
            var data = new List <string>();

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var subject =
                    repositoriesContainer.SubjectRepository.GetBy(
                        new Query <Subject>(e => e.Id == subjectId).Include(e => e.LecturesScheduleVisitings));

                data.AddRange(subject.LecturesScheduleVisitings.OrderBy(e => e.Date).Select(lecturesScheduleVisiting => lecturesScheduleVisiting.Date.ToString("dd/MM/yyyy")));
            }
            return(data);
        }
Example #54
0
        public Concept SaveConcept(Concept concept, IList <Attachment> attachments)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();
            //attachments = ProcessWordAttachmentsIfExist(attachments);
            if (!string.IsNullOrEmpty(concept.Container))
            {
                var deleteFiles =
                    repositoriesContainer.AttachmentRepository.GetAll(
                        new Query <Attachment>(e => e.PathName == concept.Container)).ToList()
                    .Where(e => attachments.All(x => x.Id != e.Id)).ToList();

                foreach (var attachment in deleteFiles)
                {
                    FilesManagementService.DeleteFileAttachment(attachment);
                }
            }
            else
            {
                concept.Container = GetGuidFileName();
            }

            FilesManagementService.SaveFiles(attachments.Where(e => e.Id == 0), concept.Container);

            foreach (var attachment in attachments)
            {
                if (attachment.Id == 0)
                {
                    attachment.PathName = concept.Container;

                    repositoriesContainer.AttachmentRepository.Save(attachment);
                }
            }

            concept.Published = attachments.Any();
            Concept source = null;

            if (concept.Id != 0)
            {
                source = GetById(concept.Id);
            }
            repositoriesContainer.ConceptRepository.Save(concept);
            repositoriesContainer.ApplyChanges();
            if (source == null)
            {
                InitNeighborConcept(concept, repositoriesContainer);
            }
            BindNeighborConcept(concept, source, repositoriesContainer);
            TryPublishParent(concept.ParentId, repositoriesContainer);
            return(concept);
        }
Example #55
0
        public IEnumerable <Test> GetTestsForSubject(int subjectId)
        {
            IEnumerable <Test> tests;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                tests = repositoriesContainer.TestsRepository.GetAll(
                    new Query <Test>(
                        test =>
                        test.SubjectId == subjectId)).ToList();
            }

            return(tests);
        }
Example #56
0
        private Question GetQuestionById(int id)
        {
            Question queston;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                queston =
                    repositoriesContainer.QuestionsRepository.GetBy(
                        new Query <Question>(question => question.Id == id)
                        .Include(question => question.Answers));
            }

            return(queston);
        }
        public int GetPidById(int PID)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                int id = 0;

                if (PID != 0)
                {
                    id = repositoriesContainer.FoldersRepository.GetPidById(PID);
                }

                return(id);
            }
        }
        public void ClearBugLogs(int bugId)
        {
            using var repositoriesContainer = new LmPlatformRepositoriesContainer();
            var bugLogs =
                repositoriesContainer.BugLogsRepository.GetAll(
                    new Query <BugLog>().AddFilterClause(u => u.BugId == bugId));

            foreach (var bugLog in bugLogs)
            {
                repositoriesContainer.BugLogsRepository.DeleteBugLog(bugLog);
            }

            repositoriesContainer.ApplyChanges();
        }
Example #59
0
        public int LabsCountByStudent(int userId)
        {
            var count = 0;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var student  = repositoriesContainer.StudentsRepository.GetStudent(userId);
                var subjects = repositoriesContainer.SubjectRepository.GetSubjects(groupId: student.GroupId).Where(e => !e.IsArchive).ToList();

                count += subjects.Sum(subject => subject.Labs.Count);
            }

            return(count);
        }
        public IList <Question> GetQuestionsByConceptId(int conceptId)
        {
            IList <Question> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Question>();
                query.AddFilterClause(question => question.ConceptId == conceptId);

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }