Exemplo n.º 1
0
        private void ChangeGroups(int userFileId, List <decimal> newGroupIds)
        {
            var groupFiles = GroupFileService.GetAll(x => x.UserFileID == userFileId)
                             .ToList();
            var currentGroupIds = groupFiles.Select(x => x.Group_ID);
            var remove          = groupFiles.Where(tc => !newGroupIds.Contains(tc.Group_ID)).ToList();

            remove.ForEach(GroupFileService.Delete);
            var add = GetGroups(newGroupIds.Except(currentGroupIds)).ToList();

            add.ForEach(x => x.UserFileID = userFileId);
            add.ForEach(GroupFileService.Insert);
            GroupFileService.SubmitChanges();
        }
Exemplo n.º 2
0
        public ActionResult Edit(int fileID)
        {
            var file = FileService.GetByPK(fileID);

            if (file.UserID != User.UserID)
            {
                throw new PermissionException("file edit");
            }
            var model = new UserFileVM {
                UserFile = file
            };

            InitModel(model);
            model.GroupIds  = GroupFileService.GetAll(x => x.UserFileID == fileID).Select(x => x.Group_ID).ToList();
            model.CourseTCs = CourseFileService.GetAll(x => x.UserFileID == fileID)
                              .Select(x => x.Course_TC).ToList();
            return(BaseView(Views.File.Edit, model));
        }
Exemplo n.º 3
0
        public ActionResult DeleteFileFrom(int fileID, string courseTC, decimal?groupID)
        {
            if (courseTC != null)
            {
                var courseFile = CourseFileService.GetAll().Where(cf =>
                                                                  cf.Course_TC == courseTC && cf.UserFileID == fileID);
                CourseFileService.DeleteAndSubmit(courseFile);
            }

            if (groupID != null)
            {
                var groupFile = GroupFileService.GetAll().Where(cf =>
                                                                cf.Group_ID == groupID && cf.UserFileID == fileID);
                GroupFileService.DeleteAndSubmit(groupFile);
            }
            FileService.SubmitChanges();
            return(RedirectBack());
        }