public async Task <ApiResponseAsync <bool> > CreatePageContent(CreateContentDTO dto) { await this._body.Create(dto.NotesId, dto.SectionId, dto.PageId, dto.Cotnent); return(ApiRes.OK(true)); }
public async Task <ApiResponseAsync <bool> > DelNotes(ObjDTO dto) { var notes = await this._notes.DelNotes(dto.Id); await this._userRoot.CatalogItemSubstructAsync(this._appUser.UserId, notes.Notes.CalelogCode, notes.Notes.GradeCode); if (notes.HasSection() == false) { return(ApiRes.OK(true)); } List <Guid> pageAryId = new List <Guid>(); foreach (var item in notes.Sections) { if (item.HasPages() == false) { continue; } pageAryId.AddRange(item.Pages.Select(p => p.Page.Id)); } if (pageAryId.Count > 0) { await this._body.Del(pageAryId.ToArray()); await this._userRoot.DelSection(this._appUser.UserId, pageAryId.ToArray()); } return(ApiRes.OK(true)); //throw new NotImplementedException(); }
public async Task <ApiResponseAsync <Guid> > CreateSection(UpdatePropDTO dto) { var id = Guid.NewGuid(); var rev = await this._notes.CreateSection(dto.Id, id, dto.Body); return(ApiRes.OK(id)); }
public Task <ApiResponseAsync <bool> > UpdatePageContent(UpdatePropDTO dto) { var rev = this._body.Update(dto.Id, dto.Body); return(ApiRes.OKAsync(rev)); }
public static ApiRes <MainGraduateDto> GraduateLazyList(GraduateFilters filters, string sort, int page, int size) { ApiRes <MainGraduateDto> res = new ApiRes <MainGraduateDto>(); sort = sort == " ," || sort == " , " ? "" : sort; filters.active = filters.active ?? new List <bool>(); filters.gender = filters.gender ?? new List <string>(); filters.didGraduate = filters.didGraduate ?? new List <bool>(); filters.hasDiploma = filters.hasDiploma ?? new List <bool>(); filters.isWork = filters.isWork ?? new List <bool>(); filters.expertise = filters.expertise ?? new List <int>(); filters.branch = filters.branch ?? new List <int>(); using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities()) { res.items = placementDepartmentDB.Graduate .Where(g => (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 && (!filters.active.Any() || filters.active.Contains(g.isActive)) && (!filters.gender.Any() || filters.gender.Contains(g.gender)) && (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) && (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) && (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) && (filters.period == 0 || filters.period == 1 && g.dateOfRegistration == DateTime.Now || filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) && (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) && (!filters.branch.Any() || filters.branch.Contains(g.branchId)) ) .OrderBy(sort + "dateOfRegistration desc") .Skip(page * size) .Take(size) .Select(g => new MainGraduateDto() { Id = g.Id, Name = g.firstName + " " + g.lastName, branchName = g.Branch.name, expertiseName = g.Expertise.name, endYear = g.endYear, isActive = g.isActive }).ToList(); res.totalCount = placementDepartmentDB.Graduate.Where(g => (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 && (!filters.active.Any() || filters.active.Contains(g.isActive)) && (!filters.gender.Any() || filters.gender.Contains(g.gender)) && (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) && (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) && (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) && (filters.period == 0 || filters.period == 1 && g.dateOfRegistration == DateTime.Now || filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) && (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) && (!filters.branch.Any() || filters.branch.Contains(g.branchId)) ).Count(); return(res); } }
public async Task <ApiResponseAsync <bool> > DelSection(ObjDTO dto) { var rev = await this._notes.DelSection(dto.Id, dto.SectionId); await this._body.Del(rev?.ToArray()); await this._userRoot.DelSection(this._appUser.UserId, dto.SectionId); return(ApiRes.OK(true)); }
public async Task <ApiResponseAsync <Guid> > CreatePage(CreatePageDTO dto) { Guid pId = Guid.NewGuid(); var rev = await this._notes.CreatePage(dto.NotesId, dto.Id, pId, dto.Body, ""); await this._body.Create(dto.NotesId, dto.Id, pId, ""); return(ApiRes.OK(rev.CurrentSection.CurrentPage.Page.Id)); }
public async Task <ApiResponseAsync <bool> > DelPage(ObjDTO dto) { var rev = await this._notes.DelPage(dto.Id, dto.SectionId, dto.PageId); await this._userRoot.DelPageAsync(this._appUser.UserId, dto.SectionId, dto.PageId); return(ApiRes.OK(rev)); //var ret = this._notes.DelSection(dto.Id, dto.SectionId); }
public static ApiRes <CoordinatingJobsForGraduatesDto> JobCoordinationLazyList(JobCoordinationFilters filters, string sort, int page, int size) { ApiRes <CoordinatingJobsForGraduatesDto> res = new ApiRes <CoordinatingJobsForGraduatesDto>(); sort = sort == " ," || sort == " , " ? "" : sort; filters.status = filters.status ?? new List <int>(); filters.branch = filters.branch ?? new List <int>(); filters.gender = filters.gender ?? new List <string>(); filters.subject = filters.subject ?? new List <int>(); filters.user = filters.user ?? new List <int>(); DateTime dateMonthAgo = DateTime.Now.AddMonths(-1); using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities()) { User cuser = placementDepartmentDB.User.Find(filters.curUserId); if (cuser.permissionId == 2) { filters.user = new List <int>(1) { cuser.Id } } ; res.items = placementDepartmentDB.CoordinatingJobsForGraduates .Where(cj => ((cuser.permissionId == 1 && !filters.user.Any()) || filters.user.Contains(cj.Job.handlesId)) && (!filters.status.Any() || filters.status.Contains(cj.placementStatus)) && (!filters.branch.Any() || filters.branch.Contains(cj.Graduate.branchId)) && (!filters.gender.Any() || filters.gender.Contains(cj.Graduate.gender)) && (filters.period == 0 || filters.period == 1 && cj.dateReceived >= dateMonthAgo || filters.period == 2 && cj.dateReceived >= filters.startDate && cj.dateReceived <= filters.endDate) && (!filters.subject.Any() || filters.subject.Contains(cj.Job.subjectId)) ) .OrderBy(sort + "dateReceived desc") .Skip(page * size) .Take(size) .ProjectTo <CoordinatingJobsForGraduatesDto>(AutoMapperConfiguration.config) .ToList(); res.totalCount = placementDepartmentDB.CoordinatingJobsForGraduates.Where(cj => ((cuser.permissionId == 1 && !filters.user.Any()) || filters.user.Contains(cj.Job.handlesId)) && (!filters.status.Any() || filters.status.Contains(cj.placementStatus)) && (!filters.branch.Any() || filters.branch.Contains(cj.Graduate.branchId)) && (!filters.gender.Any() || filters.gender.Contains(cj.Graduate.gender)) && (filters.period == 0 || filters.period == 1 && cj.dateReceived >= dateMonthAgo || filters.period == 2 && cj.dateReceived >= filters.startDate && cj.dateReceived <= filters.endDate) && (!filters.subject.Any() || filters.subject.Contains(cj.Job.subjectId)) ).Count(); return(res); } }
public static ApiRes <JobDto> JobLazyList(JobFilters filters, string sort, int page, int size) { ApiRes <JobDto> res = new ApiRes <JobDto>(); sort = sort == " ," || sort == " , " ? "" : sort; filters.sendCV = filters.sendCV ?? new List <bool>(); filters.active = filters.active ?? new List <bool>(); filters.ReasonClosing = filters.ReasonClosing ?? new List <int>(); filters.subjects = filters.subjects ?? new List <int>(); filters.user = filters.user ?? new List <int>(); DateTime dateMonthAgo = DateTime.Now.AddMonths(-1); using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities()) { User cuser = placementDepartmentDB.User.Find(filters.curUserId); if (cuser.permissionId == 2) { filters.user = new List <int>(1) { cuser.Id } } ; res.items = placementDepartmentDB.Job .Where(j => ((cuser.permissionId == 1 && !filters.user.Any()) || filters.user.Contains(j.handlesId)) && (!filters.sendCV.Any() || filters.sendCV.Contains(j.didSendCV)) && (!filters.active.Any() || filters.active.Contains(j.isActive)) && (filters.period == 0 || filters.period == 1 && j.dateReceived >= dateMonthAgo || filters.period == 2 && j.dateReceived >= filters.startDate && j.dateReceived <= filters.endDate) && (!filters.ReasonClosing.Any() || filters.ReasonClosing.Contains(j.reasonForClosing.Value)) && (!filters.subjects.Any() || filters.subjects.Contains(j.subjectId)) ) .OrderBy(sort + "dateReceived desc") .Skip(page * size) .Take(size) .ProjectTo <JobDto>(AutoMapperConfiguration.config) .ToList(); res.totalCount = placementDepartmentDB.Job.Where(j => ((cuser.permissionId == 1 && !filters.user.Any()) || filters.user.Contains(j.handlesId)) && (!filters.sendCV.Any() || filters.sendCV.Contains(j.didSendCV)) && (!filters.active.Any() || filters.active.Contains(j.isActive)) && (filters.period == 0 || filters.period == 1 && j.dateReceived >= dateMonthAgo || filters.period == 2 && j.dateReceived >= filters.startDate && j.dateReceived <= filters.endDate) && (!filters.subjects.Any() || filters.subjects.Contains(j.subjectId)) ).Count(); return(res); } }
public Task <ApiResponseAsync <Pagnation <NotesVOItem> > > NotesList(ListDTO dto) { if (dto.PageIndex <= 0) { dto.PageIndex = 1; } if (dto.PageSize <= 0) { dto.PageSize = 10; } var rev = this._qs.ListAll(dto.CatalogCode, dto.GradeCode, this._user.UserId, dto.PageSize, dto.PageIndex); return(ApiRes.OKAsync(rev)); }
public async Task <ApiResponseAsync <NotesVO> > Get(string id) { var sh = new StringHelper(id).Split(','); var nid = sh.As <Guid>(0); var pid = sh.As <Guid>(2); var nv = await this._qs.Get(nid, sh.As <Guid>(1), pid); var content = await this._body.Get(pid); nv.Body = content; return(ApiRes.OK(nv)); }
public async Task <ApiResponseAsync <Guid> > CreateNotes(CreateNotesDTO dto) { if (dto.Section != null) { dto.Section.Id = Guid.NewGuid(); } if (dto.Page != null) { dto.Page.Id = Guid.NewGuid(); } if (String.IsNullOrEmpty(dto.ClassId)) { //dto.ClassId = await this._appUser.ClassIdAsync(); } var ret = await this._notes.CreateAsync(dto, Guid.NewGuid(), this._appUser.UserName, this._appUser.UserId); await this._userRoot.ReferenceCatalog(this._appUser.UserId, dto.CatalogCode, dto.CatalogName, dto.GradeCode, dto.GradeName); return(ApiRes.OK(ret.Notes.Id)); }
public ActionResult Api(ApiReq req) { var res = new ApiRes(); switch (req.cmd) { case "LIST": var u = new SampleModel(); res.users = u.GetUsers(); break; case "SELECT": { user users = db.users.Find(req.id); if (users == null) { res.res = "NG"; } else { res.user = users; } break; } case "UPDATE": if (!ModelState.IsValid) { res.res = "NG"; } else { db.Entry(req.user).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { res.res = "NG"; res.msg = e.ToString(); } } break; case "INSERT": if (ModelState.IsValid) { db.users.Add(req.user); try { db.SaveChanges(); } catch (Exception e) { res.res = "NG"; res.msg = e.ToString(); } } break; default: res.res = "NG"; res.msg = "Bad Request"; break; } return(Json(res)); }
public Task <ApiResponseAsync <string> > PageContent(Guid id) { var rev = this._body.Get(id); return(ApiRes.OKAsync(rev)); }
public Task <ApiResponseAsync <List <ClassPageCountVO> > > PageCount(CourseCountDTO dto) { var rev = this._qs.CountPagesAsync(dto.DsId, dto.ClassId); return(ApiRes.OKAsync(rev)); }
public Task <ApiResponseAsync <bool> > UpdatePageName(UpdatePageDTO dto) { var rev = this._notes.UpdatePageName(dto.NotesId, dto.SectionId, dto.Id, dto.Body); return(ApiRes.OKAsync(rev)); }
public Task <ApiResponseAsync <bool> > UpdateNotesName(UpdatePropDTO dto) { var rev = this._notes.UpdateNotesName(dto.Id, dto.Body); return(ApiRes.OKAsync(rev)); }