public List <CategoryDto> AllCategoryItems(CategoryInputDto input) { var _queryList = (from c in _categoryRepos.GetAll() select new CategoryDto { Id = c.Id, Title = c.Title, Description = c.Description, GroupEnum = c.GroupEnum, Details = c.Details, File = c.File, ParentId = c.ParentId, Level = c.Level, IsActive = c.IsActive, SortOrder = c.SortOrder, RoleLevel = c.RoleLevel }) .WhereIf(input.GroupEnum.HasValue, p => p.GroupEnum == input.GroupEnum) .WhereIf(input.RoleLevel.HasValue, x => x.RoleLevel == input.RoleLevel); List <CategoryDto> _arList = new List <CategoryDto>(); var arrCate = _queryList.Where(x => x.Level == 0 || x.Level == null).OrderBy(x => x.SortOrder).ToList(); foreach (var cate in arrCate) { cate.Items = _queryList.Where(x => x.ParentId == cate.Id).ToList(); var arrBaiViet = _articleRepos.GetAll().Where(x => x.CategoryId == cate.Id).ToList(); cate.ArrArticles = arrBaiViet.MapTo <List <ArticleDto> >(); _arList.Add(cate); SubCategory(cate.Id, _queryList, _arList); } return(_arList); }
public async Task <PagedResultDto <CategoryDto> > GetAllServerPaging(CategoryInputDto input) { var query = (from ct in _categoryRepos.GetAll() select new CategoryDto { Id = ct.Id, Title = ct.Title, Description = ct.Description, Details = ct.Details, File = ct.File, ParentId = ct.ParentId, Level = ct.Level, IsActive = ct.IsActive, SortOrder = ct.SortOrder, RoleLevel = ct.RoleLevel }) .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.Title.Contains(input.Filter.Trim())) .WhereIf(input.RoleLevel.HasValue, p => p.RoleLevel == input.RoleLevel); var rowCount = await query.CountAsync(); var dataGrids = await query .OrderBy(p => p.SortOrder) .PageBy(input) .ToListAsync(); return(new PagedResultDto <CategoryDto>(rowCount, dataGrids)); }
public List <ItemWebDto <int> > AllCategoryToDDL(CategoryInputDto input) { var queryList = (from c in _categoryRepos.GetAll() select new ItemWebDto <int> { Id = c.Id, Title = c.Title, GroupEnum = c.GroupEnum, ParentId = c.ParentId, Level = c.Level, RoleLevel = c.RoleLevel, SortOrder = c.SortOrder }) .WhereIf(input.GroupEnum.HasValue, p => p.GroupEnum == input.GroupEnum) .WhereIf(input.CurrentId.HasValue, x => x.Id != input.CurrentId); List <ItemWebDto <int> > arrList = new List <ItemWebDto <int> >(); var arrCate = queryList.Where(x => x.Level == 0 || x.Level == null).OrderBy(x => x.SortOrder).ToList(); foreach (var cate in arrCate) { arrList.Add(cate); SubCategoryToDDL(cate.Id, "--- ", queryList, arrList); } return(arrList); }
public override PagedResultDto <CategoryDto> GetAll(CategoryInputDto input) { var query = Repository.GetAll(); query = query.Where(x => x.Name == input.Name); return(base.GetAll(input)); }
public ListResultOutput <ElementDto> GetDetailByCategory(CategoryInputDto input) { var @elements = _elementRepository .GetAll() .Where(e => e.Category == input.Category) .ToList(); return(new ListResultOutput <ElementDto>(@elements.MapTo <List <ElementDto> >())); }
public async Task <IActionResult> SearchByCategory([FromBody] CategoryInputDto category) { if (!ModelState.IsValid) { return(BadRequest()); } var reasult = await searchService.SearchByCategory(category); return(Ok(reasult)); }
/// <summary> /// 编辑分类 /// </summary> /// <param name="dto"></param> /// <returns></returns> public ActionResult Edit(CategoryInputDto dto) { Category cat = CategoryService.GetById(dto.Id); cat.Name = dto.Name; cat.Description = dto.Description; bool b = CategoryService.SaveChanges() > 0; return(ResultData(null, b, b ? "分类修改成功!" : "分类修改失败!")); }
public ActionResult Edit(CategoryInputDto dto) { Category cat = CategoryBll.GetById(dto.Id); cat.Name = dto.Name; cat.Description = dto.Description; bool b = CategoryBll.UpdateEntitySaved(cat); return(ResultData(null, b, b ? "分类修改成功!" : "分类修改失败!")); }
public PagedResultDto <CategoryDto> GetAllServerPagingLevel(CategoryInputDto input) { var arrList = AllCategory(input); var rowCount = arrList.Count(); var dataGrids = arrList .Skip(input.SkipCount) .Take(input.MaxResultCount) .ToList(); return(new PagedResultDto <CategoryDto>(rowCount, dataGrids)); }
/// <summary> /// 创建文章分类 /// </summary> /// <returns></returns> public OperateResult CreateCategory(CategoryInputDto input) { if (_unitOfWork.GetRepository <CmsCategory>().Table.Any(s => s.CategoryName == input.CategoryName)) { return(OperateResult.Error("已存在此文章分类")); } var entity = AutoMapper.Mapper.Map <CmsCategory>(input); _unitOfWork.GetRepository <CmsCategory>().Insert(entity); var row = _unitOfWork.SaveChanges(); return(row > 0 ? OperateResult.Succeed("创建成功") : OperateResult.Error("创建失败")); }
public Task <List <CategoryOutputDto> > SearchByCategory(CategoryInputDto category) { var CategoryPlaces = TuristPlaceCategoryRepository.GetQuery() .Include(x => x.Categories) .Include(y => y.TuristPlaces) .Where(z => z.Categories.Id == category.CategoryId) .Select(p => p.TuristPlaces.Id) .Select(p => mapper.Map <CategoryOutputDto>(p)) .ToListAsync(); if (CategoryPlaces == null) { throw new KeyNotFoundException("برای این دسته بندی مکان توریستی وجود ندارد"); } return(CategoryPlaces); }
public BaseResponse <bool> CreateCategory(CategoryInputDto categoryInputDto) { if (Contains(x => x.IsActivated() && x.Name.Equals(categoryInputDto.Name, StringComparison.InvariantCultureIgnoreCase))) { throw new BadRequestException($"Thể loại {categoryInputDto.Name} đã tồn tại"); } var category = Mapper.Map <Category>(categoryInputDto); Create(category, out var isSaved); if (!isSaved) { throw new BadRequestException($"Không thể tạo thể loại {category.Name}"); } return(new BaseResponse <bool>(HttpStatusCode.OK, data: true)); }
/// <summary> /// 修改文章分类 /// </summary> /// <returns></returns> public OperateResult UpdateCategory(CategoryInputDto input) { if (_unitOfWork.GetRepository <CmsCategory>().Table.Any(s => s.Id != input.Id && s.CategoryName == input.CategoryName)) { return(OperateResult.Error("已存在此文章分类")); } var existItem = _unitOfWork.GetRepository <CmsCategory>().Table.FirstOrDefault(s => s.Id == input.Id); if (existItem == null) { return(OperateResult.Error("数据不存在")); } existItem.CategoryName = input.CategoryName; existItem.CategoryDesc = input.CategoryDesc; var row = _unitOfWork.SaveChanges(); return(OperateResult.Succeed("修改成功")); }
public async Task <IActionResult> OnGetAsync() { var category = (await _categoryService.GetFilteredAsync( new CategoryQueryModel { Id = Guid.Parse(RouteData.Values["id"]?.ToString()), ApplicationUserId = HttpContext.User.Claims .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value })).FirstOrDefault(); if (category == null) { return(NotFound()); } InputDto = _mapper.Map <CategoryInputDto>(category); return(Page()); }
public BaseResponse <bool> UpdateCategory(Guid id, CategoryInputDto categoryInputDto) { var category = Find(id); if (category == null) { throw new BadRequestException($"Không tìm thấy thể loại {id}"); } category.Name = categoryInputDto.Name; var isUpdated = Update(category); if (!isUpdated) { throw new InternalServerErrorException($"Không thể update thể loại {category.Name}"); } return(new BaseResponse <bool>(HttpStatusCode.OK, data: true)); }
public async Task Post([FromBody] CategoryInputDto input) { var category = _mapper.Map <Category>(input); await _categoryManager.InsertAsync(category); }
public BaseResponse <bool> UpdateCategory(Guid id, [FromBody] CategoryInputDto categoryInputDto) { return(_categoryService.UpdateCategory(id, categoryInputDto)); }
public BaseResponse <bool> CreateCategory([FromBody] CategoryInputDto categoryInputDto) { return(_categoryService.CreateCategory(categoryInputDto)); }
public IActionResult CategoryEdit([FromBody] CategoryInputDto input) { var result = _articleService.UpdateCategory(input); return(Ok(result)); }