/// <summary> /// Возвращает постраничный список эл-тов карты сайта /// </summary> /// <param name="filter"></param> /// <returns></returns> public PageModel[] GetPages(PageFilterModel filter) { using (var db = new CMSdb(_context)) { var q = db.core_pages .Where(w => w.fkpagesites.id == _siteId); if (filter.GroupId != null) { q = q.Join(db.core_page_group_links.Where(w => w.f_page_group == filter.GroupId), n => n.gid, m => m.f_page, (n, m) => new { n, m }) .OrderBy(o => o.m.n_sort) .Select(s => s.n); } else { q = q.Where(w => w.pgid == filter.Parent).OrderBy(o => o.n_sort); } return(q .Select(s => new PageModel { Id = s.gid, Name = s.c_name, ParentId = s.pgid, Sort = s.n_sort, IsDisabled = s.b_disabled, CountChilds = db.core_pages .Where(w => w.pgid == s.gid) .Count() }).ToArray()); } }
public async Task <IActionResult> GetAsync([FromQuery] PageFilterModel model) { // This mapping exists only to handle sort values mismatch (-1 and 1 instead of 0 and 1). // For a new project it'd be better to update the client to send the same values. var sort = model.Sort != null ? model.Sort .Select(x => new SortField { FieldName = x.Key, Direction = x.Value == 1 ? SortDirection.Ascending : SortDirection.Descending }) .ToList() : null; var filter = new UserFilter { SearchValue = model.SearchValue, AsNoTracking = true }; Expression <Func <User, UserViewModel> > map = x => new UserViewModel { Id = x.Id.ToString(), FirstName = x.FirstName, LastName = x.LastName, Email = x.Email }; var page = await _userService.FindPageAsync(filter, sort, model.Page, model.PerPage, map); return(Ok(page)); }
public async Task <ActionResult> ProductList(int _groupId, [FromBody] PageFilterModel _model) { string link = URI_API.PRODUCT_GROUP_SEARCH_PRODUCT.Replace("{id}", $"{_groupId}"); ResponseConsult <PagedList <ProductModel> > response = await PostAsJsonAsync <PagedList <ProductModel> >(link, _model); return(Ok(response)); }
// // GET: /Category/Create public ActionResult AddCategory() { string Categoryid = Request.QueryString["q"]; Session["PageFilterModel"] = new PageFilterModel(); ProductDataContext db = new ProductDataContext(); CategoryModel loCategoryModel = new CategoryModel(); loCategoryModel.CategoryID = 0; loCategoryModel.CategoryName = ""; try { if (!string.IsNullOrEmpty(Categoryid)) { var locategory = db.tblCategories.Where(x => x.CategoryId == Convert.ToInt32(Categoryid)).FirstOrDefault(); loCategoryModel.CategoryID = locategory.CategoryId; loCategoryModel.CategoryName = locategory.CategoryName; } } catch (Exception ex) { throw; } return(View(loCategoryModel)); }
public ActionResult ProductDetail(PageFilterModel paging) { if (Session["PageFilterModel"] != null) { paging = (PageFilterModel)Session["PageFilterModel"]; } ProductDataContext db = new ProductDataContext(); List <ProductModel> lloProductModel = new List <ProductModel>(); try { int totalrecord = 0; var categoryobj = db.SP_SELECTProduct(paging.PageNo, paging.PageSize); foreach (var item in categoryobj) { totalrecord = item.TotalRow ?? 0; lloProductModel.Add(new ProductModel { ProductID = item.ProductId, ProductName = item.ProductName, CategoryID = item.CategoryId, CategoryName = item.CategoryName }); } int totalPages_pre = (totalrecord / 10); paging.totalpage = (totalrecord % 10) == 0 ? totalPages_pre : totalPages_pre + 1; paging.totalRecord = totalrecord; } catch (Exception) { throw; } ViewBag.paging = paging; return(View(lloProductModel)); }
public async Task <ActionResult> BranchList(int _supplierId, [FromBody] PageFilterModel _model) { string link = URI_API.SUPPLIER_SEARCH_BRANCH.Replace("{id}", $"{_supplierId}"); ResponseConsult <PagedList <SupplierBranchModel> > response = await PostAsJsonAsync <PagedList <SupplierBranchModel> >(link, _model); return(Ok(response)); }
public ActionResult sessionvalueset(string pageno) { PageFilterModel loPageFilterModel = new PageFilterModel(); loPageFilterModel.PageNo = Convert.ToInt32(pageno); Session["PageFilterModel"] = loPageFilterModel; return(Json("success")); }
public async Task <PagedList <Supplier> > GetList(PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); var items = await context.Supplier.Where(i => i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) ).OrderByDescending(i => i.Id).GetPagedList(_model.Page, _model.PageSize); return(items); }
public async Task <PagedList <SupplierBranch> > GetBranchs(int _branchId, PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); var items = await context.SupplierBranch.Where(i => i.SupplierId == _branchId && i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) ).OrderByDescending(i => i.UpdatedDate.HasValue ? i.UpdatedDate : i.CreatedDate).GetPagedList(_model.Page, _model.PageSize); return(items); }
public async Task <PagedList <Product> > GetLivestockList(PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); var GIONG_NUOI = (int)SystemIDEnum.ProductGroup_LivestockSeed; var items = await context.Product.Where(i => i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) && i.ProductGroupId == GIONG_NUOI ).OrderByDescending(i => i.UpdatedDate.HasValue ? i.UpdatedDate : i.CreatedDate).GetPagedList(_model.Page, _model.PageSize); return(items); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model, string type = "stock") { ResponseConsult <PagedList <ProductModel> > response = null; if (type == "livestock") { response = await PostAsJsonAsync <PagedList <ProductModel> >(URI_API.PRODUCT_SEARCH_LIVESTOCK, _model); } else { response = await PostAsJsonAsync <PagedList <ProductModel> >(URI_API.PRODUCT_SEARCH, _model); } return(Ok(response)); }
public async Task <PagedList <FarmingSeason> > GetList(PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); int filter = 0; if (_model.Filters != null && _model.Filters.Count > 0 && _model.Filters[0].Key == FilterEnum.FishPond) { int.TryParse(_model.Filters[0].Value + "", out filter); } var items = await context.FarmingSeason.Where(i => i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) && (filter == 0 || i.FishPondId == filter) ).OrderByDescending(i => i.Id).GetPagedList(_model.Page, _model.PageSize); return(items); }
public ActionResult AddProduct() { string productid = Request.QueryString["q"]; Session["PageFilterModel"] = new PageFilterModel(); ProductModel loProductModel = new ProductModel(); loProductModel.ProductID = 0; loProductModel.ProductName = ""; loProductModel.CategoryID = 0; loProductModel.CategoryName = ""; ProductDataContext db = new ProductDataContext(); List <SelectListItem> Category = new List <SelectListItem>(); try { if (!string.IsNullOrEmpty(productid)) { var loproduct = db.tblProducts.Where(x => x.ProductId == Convert.ToInt32(productid)).FirstOrDefault(); loProductModel.ProductID = loproduct.ProductId; loProductModel.ProductName = loproduct.ProductName; loProductModel.CategoryID = loproduct.CategoryId ?? 0; loProductModel.CategoryName = ""; } var llcategory = db.tblCategories.ToList(); Category.Add(new SelectListItem { Text = "Select Category", Value = "0" }); foreach (var item in llcategory) { Category.Add(new SelectListItem { Text = item.CategoryName, Value = item.CategoryName }); } } catch (Exception) { throw; } ViewBag.Category = Category; return(View(loProductModel)); }
public async Task <PagedList <FishPondModel> > GetList(PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); int filter = 0; if (_model.Filters != null && _model.Filters.Count > 0 && _model.Filters[0].Key == FilterEnum.FarmRegion) { int.TryParse(_model.Filters[0].Value + "", out filter); } // lấy ds var items = await context.FishPond.Where(i => i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) && (filter == 0 || i.FarmRegionId == filter) ).OrderByDescending(i => i.Id).GetPagedList(_model.Page, _model.PageSize); PagedList <FishPondModel> result = iMapper.Map <PagedList <FishPondModel> >(items); // lấy ds kho tương ứng var idList = items.Items.Select(i => i.WarehouseId); var defaultWarehouses = await context.Warehouse .Where(x => idList.Contains(x.Id)) .Join(context.Warehouse, wh => wh.DefaultWarehouseId, dwh => dwh.Id, (wh, dwh) => new { warehouseId = wh.Id, defaultWarehouseId = dwh.Id, defaultWarehouseName = dwh.Name }) .ToListAsync(); result.Items.ForEach(i => { var dWh = defaultWarehouses.FirstOrDefault(d => i.WarehouseId == d.warehouseId); if (dWh != null) { i.DefaultWarehouseId = dWh.defaultWarehouseId; i.DefaultWarehouseName = dWh.defaultWarehouseName; } }); return(result); }
public async Task <IActionResult> GetAsync([FromQuery] PageFilterModel model) { // This mapping exists only to handle sort values mismatch (-1 and 1 instead of 0 and 1). // For a new project it'd be better to update the client to send the same values. var sort = model.Sort != null ? model.Sort .Select(x => (x.Key, x.Value == 1 ? SortDirection.Ascending : SortDirection.Descending)) .ToList() : null; var page = await _userService.FindPageAsync( new UserFilter { SearchValue = model.SearchValue }, sort, model.Page, model.PerPage ); var pageModel = _mapper.Map <PageModel <UserViewModel> >(page); return(Ok(pageModel)); }
public ActionResult CategoryDetail(PageFilterModel paging) { ProductDataContext db = new ProductDataContext(); List <CategoryModel> lloCategoryModel = new List <CategoryModel>(); try { var categoryobj = db.SP_SELECTCategory(paging.PageNo, paging.PageSize); foreach (var item in categoryobj) { lloCategoryModel.Add(new CategoryModel { CategoryID = item.CategoryId, CategoryName = item.CategoryName }); } } catch (Exception) { throw; } return(View(lloCategoryModel)); }
public async Task <PagedList <Product> > GetStockList(PageFilterModel _model) { _model.Key = string.IsNullOrWhiteSpace(_model.Key) ? null : _model.Key.Trim(); int filter = 0; if (_model.Filters != null && _model.Filters.Count > 0 && _model.Filters[0].Key == FilterEnum.ProductGroup) { int.TryParse(_model.Filters[0].Value + "", out filter); } var GIONG_NUOI = (int)SystemIDEnum.ProductGroup_LivestockSeed; if (filter == GIONG_NUOI) { return(null); } var items = await context.Product.Where(i => i.IsDeleted == false && (_model.Key == null || i.Name.Contains(_model.Key)) && i.ProductGroupId != GIONG_NUOI && (filter == 0 || i.ProductGroupId == filter) ).OrderByDescending(i => i.Id).GetPagedList(_model.Page, _model.PageSize); return(items); }
public async Task <IActionResult> Search([FromBody] PageFilterModel _model) { var result = await busWarehouse.GetList(_model); return(Ok(context.WrapResponse(result))); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model) { ResponseConsult <PagedList <FishPondModel> > response = await PostAsJsonAsync <PagedList <FishPondModel> >(URI_API.FISH_POND_SEARCH, _model); return(Ok(response)); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model) { ResponseConsult <PagedList <WarehouseModel> > response = await PostAsJsonAsync <PagedList <WarehouseModel> >(URI_API.WAREHOUSE_SEARCH, _model); return(Ok(response)); }
public async Task <PagedList <FarmingSeasonModel> > GetList(PageFilterModel _model) { return(iMapper.Map <PagedList <FarmingSeasonModel> >(await svcFarmingSeason.GetList(_model))); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model) { ResponseConsult <PagedList <ProductGroupModel> > response = await PostAsJsonAsync <PagedList <ProductGroupModel> >(URI_API.PRODUCT_GROUP_SEARCH, _model); return(Ok(response)); }
public async Task <PagedList <TaxPercentModel> > GetList(PageFilterModel _model) { return(iMapper.Map <PagedList <TaxPercentModel> >(await svcTaxPercent.GetList(_model))); }
public async Task <PagedList <WarehouseModel> > GetList(PageFilterModel _model) { return(iMapper.Map <PagedList <WarehouseModel> >(await svcWarehouse.GetList(_model))); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model) { ResponseConsult <PagedList <StockReceiveDocketModel> > response = await PostAsJsonAsync <PagedList <StockReceiveDocketModel> >(URI_API.STOCK_RECEIVE_DOCKET_SEARCH, _model); return(Ok(response)); }
public async Task <PagedList <ProductUnitProductModel> > GetList(PageFilterModel _model) { return(iMapper.Map <PagedList <ProductUnitProductModel> >(await svcProductUnitProduct.GetList(_model))); }
public async Task <PagedList <ProductModel> > GetProducts(int _subgroupId, PageFilterModel _model) { return(iMapper.Map <PagedList <ProductModel> >(await svcProductSubgroup.GetProducts(_subgroupId, _model))); }
public async Task <PagedList <FishPondModel> > GetList(PageFilterModel _model) { return(await svcFishPond.GetList(_model)); }
public async Task <ActionResult> List([FromBody] PageFilterModel _model) { ResponseConsult <PagedList <FarmingSeasonModel> > response = await PostAsJsonAsync <PagedList <FarmingSeasonModel> >(URI_API.FARMING_SEASON_SEARCH, _model); return(Ok(response)); }
public async Task <PagedList <CustomerModel> > GetList(PageFilterModel _model) { return(iMapper.Map <PagedList <CustomerModel> >(await svcCustomer.GetList(_model))); }