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 }); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } }
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); }
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); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }