Esempio n. 1
0
        public async Task <CatalogVO> CatalogEnableFilterAsync(string userId, string termIdx, string subjectIdx)
        {
            var u = await this._userLoader.Load(userId);

            if (this._userLoader.IsFromDb)
            {
                await this._userLoader.Save(u);
            }

            Prosecutor.NotNull(u);


            if (u.Catalog == null)
            {
                return(null);
            }


            var helper = new CatalogHelper(u, termIdx, subjectIdx)
                         .Filter()
                         .OrderBy();


            return(new CatalogVO
            {
                Subject = helper.Subject, //subject,
                Term = helper.Term
            });
        }
Esempio n. 2
0
        internal SectionValue DelSection(Guid sId)
        {
            var section = this.Sections.FirstOrDefault(s => s.Sections.Id == sId);

            Prosecutor.NotNull(section);
            this.Sections.Remove(new SectionValue(new NotesSectionEntity {
                Id = sId
            }));

            return(section);
        }
Esempio n. 3
0
        public async Task <NotesObj> Get(Guid nid, Guid sectionId, Guid pid)
        {
            var notes = await this._loader.LoadAsync(nid);

            Prosecutor.NotNull(notes);
            notes
            ?.SetSection(sectionId)
            ?.SetCurrentPage(pid);



            return(notes);
        }
Esempio n. 4
0
        SectionValue GetSection(Guid sid)
        {
            if (this.HasSection() == false)
            {
                throw new NotesValidateExceptions("该笔记不包含分区");
            }

            var st = this.Sections.FirstOrDefault(s => s.Sections.Id == sid);

            Prosecutor.NotNull(st);

            return(st);
        }
Esempio n. 5
0
        public async Task <bool> ReplaceCollaboratorAsync(string courseId, int operatorId, CollabratorDTO dto)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空:{courseId}");
            course.Apply(this.toolbox.DomainSetter[DomainSetter.Mapper]);
            course.ReplaceCollaborator(dto, operatorId);
            await this._loader.Save(course);

            this._vf.Save(course, c => c.CollaboratorLib);

            return(true);
        }
Esempio n. 6
0
        public async Task <bool> Delete(string courseId, int operaoterId)
        {
            var course = await this.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息不能为空{courseId}");

            course.Delete(operaoterId);

            await this.toolbox.Cachor.Remove(this.cacheKey(courseId));

            await this.toolbox.Sender.SendAsync(course.Events);

            return(true);
        }
Esempio n. 7
0
        public async Task <bool> SchoolReviewCancel(string courseId, int operatorId)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空");
            bool rev = course.SchoolReviewCancel(operatorId);

            if (rev == false)
            {
                return(false);
            }
            await this._loader.Save(course);

            return(true);
        }
Esempio n. 8
0
        public async Task <Course> LeanerLeave(int userId, string courseId)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空");
            var rev = course.LeanerLeave(userId);

            if (rev == false)
            {
                return(null);
            }
            await this._loader.Save(course);

            return(course);
        }
Esempio n. 9
0
        public async Task CatalogItemSubstructAsync(string userId, string catalogCode, string gradeCode)
        {
            var u = await this._loader.Load(userId);

            Prosecutor.NotNull(u);
            u.CatalogItemSubstruct(catalogCode, gradeCode);

            await this._loader.Save(u);

            foreach (var item in u.Events)
            {
                await
                this._sender.SendAsync(item, item.GetType().Name);
            }
        }
Esempio n. 10
0
        public async Task <NotesObj> LoadAsync(Guid id)
        {
            string key = string.Concat(this._opt.Value.NotesCachePrefix, id);

            var rev = await this._cachor.Get <NotesObj>(key);

            if (rev == null)
            {
                rev = await this.FromDb(id);
            }

            Prosecutor.NotNull(rev);

            return(rev);
        }
Esempio n. 11
0
        public async Task ReferenceCatalog(string userId, string catalogCode, string catalogName,
                                           string gradecode, string gradeName)
        {
            var u = await this._loader.Load(userId);

            Prosecutor.NotNull(u);
            u.ReferenceCatalog(catalogCode, catalogName, gradecode, gradeName);

            await this._loader.Save(u);

            foreach (var item in u.Events)
            {
                await this._sender.SendAsync(item, item.GetType().Name);
            }
        }
Esempio n. 12
0
        public async Task <bool> UpdateDs(UpdateDsDTO dto, int userId)
        {
            var course = await this._loader.LoaderAsync(dto.CourseId);

            Prosecutor.NotNull(course, "课程信息不存在");
            bool result = course.UpdateDs(dto, userId);

            if (result is false)
            {
                return(false);
            }

            await this._loader.Save(course);

            return(true);
        }
Esempio n. 13
0
        public async Task <bool> DelDs(string courseId, int catalogId, Guid dsId, int operatorId)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空:{courseId}");


            bool result = course.DelDs(catalogId, dsId, operatorId);

            if (!result)
            {
                return(false);
            }

            await this._loader.Save(course);

            return(true);
        }
Esempio n. 14
0
        internal bool UpdatePageName(Guid pid, string name)
        {
            if (this.HasPages() == false)
            {
                throw new NotesValidateExceptions("对象不存在");
            }
            var page = this.Pages.FirstOrDefault(p => p.Page.Id == pid);

            Prosecutor.NotNull(page);

            if (page.Page.Name.Equals(name))
            {
                return(false);
            }

            page.Page.Name = name;

            return(true);
        }
Esempio n. 15
0
        public async Task <Course> LeanerJoin(int userId, string pltUserId, string courseId)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空");
            //if (course.Status != CourseStatus.Listed || course.RegionStatus != CourseStatus.RegionListed)
            //{
            //    throw new CPValidateExceptions("无法加入未上架的课程");
            //}
            var rev = course.JoinLeaner(userId, pltUserId);

            if (rev == false)
            {
                return(null);
            }
            await this._loader.Save(course);

            return(course);
        }
Esempio n. 16
0
        public UserItem GetUser(string session)
        {
            //await Task.CompletedTask;

            //return new UserItem
            //{
            //    UserID = 1222,
            //    RealName = "hello"
            //};

            var rev = this.Get <UserInfoDTO>(session, this._opt.Value.UserSessionUriPart);

            var user = rev.Result.FirstOrDefault();

            Prosecutor.NotNull(user);


            return(user);
        }
Esempio n. 17
0
        public async Task <bool> RegionReview(string courseId, int operatorId)
        {
            var course = await this._loader.LoaderAsync(courseId);

            Prosecutor.NotNull(course, $"课程信息为空");

            if ((await this._pm.IsSchoolAuditorAsync(course.School.Code)) is false)
            {
                throw new CPPermissionException();
            }

            bool rev = course.RegionReview(operatorId);

            if (rev == false)
            {
                return(false);
            }
            await this._loader.Save(course);

            return(true);
        }
Esempio n. 18
0
        public async Task RegionRejectAsync(CourseAuditCommand cmd, Course root = null)
        {
            if (this._pm.IsRegionAuditor == false)
            {
                throw new CPPermissionException();
            }

            var course = root ?? await this._loader.LoaderAsync(cmd.CourseId);

            Prosecutor.NotNull(course, $"课程信息为空");

            if (course.Region.Code != cmd.ReviewerOrgId)
            {
                throw new CPPermissionException();
            }

            course.Apply(this.toolbox.DomainSetter[DomainSetter.Mapper]);

            course.RegionReject(cmd);

            await this._loader.Save(course);
        }