Exemplo n.º 1
0
        public void DeletePracticals(int id)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var practicals =
                    repositoriesContainer.PracticalRepository.GetBy(
                        new Query <Practical>(e => e.Id == id).Include(e => e.StudentPracticalMarks));

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

                var studentPracticalsMarks =
                    repositoriesContainer.RepositoryFor <StudentPracticalMark>()
                    .GetAll(new Query <StudentPracticalMark>(e => e.PracticalId == id))
                    .ToList();

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

                foreach (var mark in studentPracticalsMarks)
                {
                    repositoriesContainer.RepositoryFor <StudentPracticalMark>().Delete(mark);
                }

                repositoriesContainer.ApplyChanges();

                repositoriesContainer.PracticalRepository.Delete(practicals);

                repositoriesContainer.ApplyChanges();
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public Labs SaveLabs(Labs labs, IList <Attachment> attachments, Int32 userId)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                if (!string.IsNullOrEmpty(labs.Attachments))
                {
                    var deleteFiles =
                        repositoriesContainer.AttachmentRepository.GetAll(
                            new Query <Attachment>(e => e.PathName == labs.Attachments)).ToList().Where(e => attachments.All(x => x.Id != e.Id)).ToList();

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

                FilesManagementService.SaveFiles(attachments.Where(e => e.Id == 0), labs.Attachments);

                foreach (var attachment in attachments)
                {
                    if (attachment.Id == 0)
                    {
                        attachment.PathName = labs.Attachments;
                        repositoriesContainer.AttachmentRepository.Save(attachment);
                    }
                }

                repositoriesContainer.LabsRepository.Save(labs);
                repositoriesContainer.ApplyChanges();

                if (labs.IsNew && !labs.Subject.SubjectModules.Any(m => m.Module.ModuleType == ModuleType.Practical) &&
                    labs.Subject.SubjectModules.Any(m => m.Module.ModuleType == ModuleType.Labs))
                {
                    ConceptManagementService.AttachFolderToLabSection(labs.Theme, userId, labs.SubjectId);
                }
            }

            return(labs);
        }
Exemplo n.º 4
0
        public void DeleteLection(Lectures lectures)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var lectModel =
                    repositoriesContainer.LecturesRepository.GetBy(new Query <Lectures>(e => e.Id == lectures.Id));
                var deleteFiles =
                    repositoriesContainer.AttachmentRepository.GetAll(
                        new Query <Attachment>(e => e.PathName == lectModel.Attachments)).ToList();

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

                repositoriesContainer.SubjectRepository.DeleteLection(lectures);
                repositoriesContainer.ApplyChanges();
            }
        }
Exemplo n.º 5
0
        public UserLabFiles SaveUserLabFiles(UserLabFiles userLabFiles, IList <Attachment> attachments)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                if (!string.IsNullOrEmpty(userLabFiles.Attachments))
                {
                    var deleteFiles =
                        repositoriesContainer.AttachmentRepository.GetAll(
                            new Query <Attachment>(e => e.PathName == userLabFiles.Attachments)).ToList().Where(e => attachments.All(x => x.Id != e.Id)).ToList();

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

                FilesManagementService.SaveFiles(attachments.Where(e => e.Id == 0), userLabFiles.Attachments);

                foreach (var attachment in attachments)
                {
                    if (attachment.Id == 0)
                    {
                        attachment.PathName = userLabFiles.Attachments;
                        repositoriesContainer.AttachmentRepository.Save(attachment);
                    }
                }

                repositoriesContainer.RepositoryFor <UserLabFiles>().Save(userLabFiles);
                repositoriesContainer.ApplyChanges();
            }

            return(userLabFiles);
        }