Example #1
0
        public ActionResult GetFileSubject(string subjectId)
        {
            var lectures = new List <Attachment>();

            foreach (var att in SubjectManagementService.GetLecturesAttachments(int.Parse(subjectId)))
            {
                lectures.AddRange(FilesManagementService.GetAttachments(att).ToList());
            }

            var labs = new List <Attachment>();

            foreach (var att in SubjectManagementService.GetLabsAttachments(int.Parse(subjectId)))
            {
                lectures.AddRange(FilesManagementService.GetAttachments(att).ToList());
            }

            var practicals = new List <Attachment>();

            foreach (var att in SubjectManagementService.GetPracticalsAttachments(int.Parse(subjectId)))
            {
                lectures.AddRange(FilesManagementService.GetAttachments(att).ToList());
            }

            return(new JsonResult()
            {
                Data = new
                {
                    Lectures = this.PartialViewToString("Subjects/Modules/_FilesUploaderNoAdd", lectures),
                    Labs = this.PartialViewToString("Subjects/Modules/_FilesUploaderNoAdd", labs),
                    Practicals = this.PartialViewToString("Subjects/Modules/_FilesUploaderNoAdd", practicals)
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #2
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();
            }
        }
Example #3
0
        public FileResult GetStudentZipLabs(int id, int subjectId, int userId)
        {
            var zip = new ZipFile(Encoding.UTF8);

            var subGroups = SubjectManagementService.GetSubGroup(id);

            var subGroup = subGroups.SubjectStudents.FirstOrDefault(e => e.StudentId == userId);

            var model = SubjectManagementService.GetUserLabFiles(subGroup.StudentId, subjectId);

            var attachments = new List <Attachment>();

            foreach (var data in model)
            {
                attachments.AddRange(FilesManagementService.GetAttachments(data.Attachments));
            }

            UtilZip.CreateZipFile(ConfigurationManager.AppSettings["FileUploadPath"], zip, attachments, subGroup.Student.FullName.Replace(" ", "_"));

            var memoryStream = new MemoryStream();

            zip.Save(memoryStream);

            memoryStream.Seek(0, SeekOrigin.Begin);

            return(new FileStreamResult(memoryStream, "application/zip")
            {
                FileDownloadName = subGroup.Student.FullName.Replace(" ", "_") + ".zip"
            });
        }
Example #4
0
 public LecturesDataViewModel(Lectures lectures)
 {
     Theme       = lectures.Theme;
     LecturesId  = lectures.Id;
     Duration    = lectures.Duration;
     SubjectId   = lectures.SubjectId;
     Order       = lectures.Order;
     PathFile    = lectures.Attachments;
     Attachments = FilesManagementService.GetAttachments(lectures.Attachments);
 }
Example #5
0
 public PracticalsViewData(Practical practical)
 {
     Theme       = practical.Theme;
     PracticalId = practical.Id;
     Duration    = practical.Duration;
     SubjectId   = practical.SubjectId;
     Order       = practical.Order;
     PathFile    = practical.Attachments;
     ShortName   = practical.ShortName;
     Attachments = FilesManagementService.GetAttachments(practical.Attachments);
 }
 public LabsViewData(LMP.Models.Labs labs)
 {
     Theme       = labs.Theme;
     LabId       = labs.Id;
     Duration    = labs.Duration;
     SubjectId   = labs.SubjectId;
     Order       = labs.Order;
     PathFile    = labs.Attachments;
     ShortName   = labs.ShortName;
     Attachments = FilesManagementService.GetAttachments(labs.Attachments);
 }
Example #7
0
        public ActionResult GetFilePracticals(int id)
        {
            if (id == 0)
            {
                return(PartialView("Common/_FilesUploader", new List <Attachment>()));
            }

            var model = SubjectManagementService.GetPractical(id);

            return(PartialView("Common/_FilesUploader", FilesManagementService.GetAttachments(model.Attachments).ToList()));
        }
Example #8
0
        private AttachViewData GetNeighborConceptData(Int32 neighborId)
        {
            var neighbor = ConceptManagementService.GetById(neighborId);

            if (neighbor == null)
            {
                return(new AttachViewData(0, String.Empty, null));
            }
            var att = FilesManagementService.GetAttachments(neighbor.Container).FirstOrDefault();

            return(new AttachViewData(neighbor.Id, neighbor.Name, att));
        }
Example #9
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 #10
0
 public LecturesDataViewModel(int id, int subjectId)
 {
     SubjectId   = subjectId;
     Attachments = new List <Attachment>();
     if (id != 0)
     {
         var lectures = SubjectManagementService.GetLectures(id);
         Order       = lectures.Order;
         Theme       = lectures.Theme;
         Duration    = lectures.Duration;
         LecturesId  = id;
         PathFile    = lectures.Attachments;
         Attachments = FilesManagementService.GetAttachments(lectures.Attachments);
     }
 }
Example #11
0
 public PracticalsDataViewModel(int id, int subjectId)
 {
     SubjectId   = subjectId;
     Attachments = new List <Attachment>();
     if (id != 0)
     {
         var practicals = SubjectManagementService.GetPractical(id);
         Order       = practicals.Order;
         Theme       = practicals.Theme;
         Duration    = practicals.Duration;
         PracticalId = id;
         ShortName   = practicals.ShortName;
         PathFile    = practicals.Attachments;
         Attachments = FilesManagementService.GetAttachments(practicals.Attachments);
     }
 }
Example #12
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);
        }
Example #13
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();
            }
        }
Example #14
0
        public AddOrEditConceptViewModel(Int32 currentAuthorId, Int32 id)
            : base(currentAuthorId, id)
        {
            if (!IsNew())
            {
                Container = SourceConcept.Container;
                if (!String.IsNullOrEmpty(Container))
                {
                    Attachments = FilesManagementService.GetAttachments(Container);
                }
                ParentId = SourceConcept.ParentId.GetValueOrDefault();
                IsGroup  = SourceConcept.IsGroup;
                Prev     = SourceConcept.PrevConcept;
                Next     = SourceConcept.NextConcept;
            }


            //Attachments = new List<Attachment>();
        }
Example #15
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);
        }