Ejemplo n.º 1
0
        public List <Product> GetLstProduct(FilterObj filter, List <Product> lstDefault)
        {
            var lstProduct = new List <Product>();

            lstProduct = lstDefault.Take(100).ToList();
            if (filter.Stuff != null)
            {
                lstProduct = lstDefault.Where(n => n.Stuff.Contains(filter.Stuff)).Take(100).ToList();
            }

            if (filter.Subtype != null)
            {
                lstProduct = lstDefault.Where(n => n.ProductSubTypeId == filter.Subtype).Take(100).ToList();
            }

            if (filter.ProductType != null)
            {
                lstProduct = lstDefault.Where(n => n.ProductTypeId == filter.ProductType).Take(100).ToList();
            }

            if (filter.Search != null)
            {
                lstProduct = lstDefault.Where(n => n.Name.ToUpper().Contains(filter.Search.ToUpper()) || n.Code.ToUpper().Contains(filter.Search.ToUpper())).Take(100).ToList();
            }

            if (filter.PriceFrom > 0 && filter.PriceTo > 0)
            {
                lstProduct = lstDefault.Where(n => n.Price >= filter.PriceFrom && n.Price <= filter.PriceTo).Take(100).ToList();
            }

            return(lstProduct);
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PostQuery(JObject jsonData)
        {
            TransferObj <PagedObj <NvXuatKhacVm.Dto> > result = new TransferObj <PagedObj <NvXuatKhacVm.Dto> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvXuatKhacVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvXuatKhacVm.Search> >();

            filtered.OrderBy   = "NgayCT";
            filtered.OrderType = "DESC";
            PagedObj <NvVatTuChungTu> paged = ((JObject)postData.paged).ToObject <PagedObj <NvVatTuChungTu> >();
            string       unitCode           = _service.GetCurrentUnitCode();
            QueryBuilder query = new QueryBuilder
            {
                Take = paged.ItemsPerPage,
                Skip = paged.FromItem - 1,

                Filter = new QueryFilterLinQ()
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().LoaiPhieu),
                            Method   = FilterMethod.EqualTo,
                            Value    = TypeVoucher.XKHAC.ToString()
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().UnitCode),
                            Method   = FilterMethod.EqualTo,
                            Value    = unitCode
                        }
                    },
                    Method = FilterMethod.And
                },
                Orders = new List <IQueryOrder>()
                {
                    new QueryOrder()
                    {
                        Field  = ClassHelper.GetPropertyName(() => new NvVatTuChungTu().ICreateDate),
                        Method = OrderMethod.DESC
                    }
                }
            };

            try
            {
                ResultObj <PagedObj <NvVatTuChungTu> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }
                result.Data   = Mapper.Map <PagedObj <NvVatTuChungTu>, PagedObj <NvXuatKhacVm.Dto> >(filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> PostQuery(JObject jsonData)
        {
            TransferObj <PagedObj <NvCongNoVm.Dto> > result = new TransferObj <PagedObj <NvCongNoVm.Dto> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvCongNoVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvCongNoVm.Search> >();
            PagedObj <NvCongNo>           paged    = ((JObject)postData.paged).ToObject <PagedObj <NvCongNo> >();
            string       unitCode = _service.GetCurrentUnitCode();
            QueryBuilder query    = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ()
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvCongNo().LoaiChungTu),
                            Method   = FilterMethod.EqualTo,
                            Value    = filtered.AdvanceData.LoaiChungTu
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvCongNo().UnitCode),
                            Method   = FilterMethod.EqualTo,
                            Value    = unitCode
                        }
                    },
                    Method = FilterMethod.And
                },
                Orders = new List <IQueryOrder>()
                {
                    new QueryOrder()
                    {
                        Field  = ClassHelper.GetPropertyName(() => new NvCongNo().ICreateDate),
                        Method = OrderMethod.DESC
                    }
                }
            };

            try
            {
                ResultObj <PagedObj <NvCongNo> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }
                result.Data   = Mapper.Map <PagedObj <NvCongNo>, PagedObj <NvCongNoVm.Dto> >(filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception e)
            {
                WriteLogs.LogError(e);
                result.Status  = false;
                result.Message = e.Message.ToString();
                return(Ok(result));
            }
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> PostQuerySummary(JObject jsonData)
        {
            TransferObj <PagedObj <NvPhieuDatHangNCCVm.Dto> > result = new TransferObj <PagedObj <NvPhieuDatHangNCCVm.Dto> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvPhieuDatHangNCCVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvPhieuDatHangNCCVm.Search> >();

            filtered.OrderType = "DESC";
            filtered.OrderBy   = "Ngay";
            PagedObj <NvDatHang> paged = ((JObject)postData.paged).ToObject <PagedObj <NvDatHang> >();
            string       unitCode      = _service.GetCurrentUnitCode();
            QueryBuilder query         = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ()
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().SoPhieuCon),
                            Method   = FilterMethod.NotNull,
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().Loai),
                            Method   = FilterMethod.EqualTo,
                            Value    = (int)LoaiDatHang.NHACUNGCAP
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().UnitCode),
                            Method   = FilterMethod.EqualTo,
                            Value    = unitCode
                        }
                    },
                    Method = FilterMethod.And
                },
            };

            try
            {
                ResultObj <PagedObj <NvDatHang> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }

                result.Data   = Mapper.Map <PagedObj <NvDatHang>, PagedObj <NvPhieuDatHangNCCVm.Dto> >(filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 5
0
        public virtual IQueryFilter FilterSQL <TSearch>(
            FilterObj <TSearch> filtered,
            IQueryBuilder query = null)
            where TSearch : IDataSearch
        {
            query = query ?? new QueryBuilder();
            // load filter
            var advanceData = filtered.AdvanceData;

            if (!filtered.IsAdvance)
            {
                advanceData.LoadGeneralParam(filtered.Summary);
            }
            var filters = advanceData.GetFilters();

            if (filters.Count > 0)
            {
                var newQuery = new QueryFilterSQL
                {
                    Method     = filtered.IsAdvance ? FilterMethod.And : FilterMethod.Or,
                    SubFilters = filters,
                };
                if (query.Filter == null)
                {
                    query.Filter = newQuery;
                }
                else
                {
                    query.Filter.MergeFilter(newQuery);
                }
            }
            var quickFilters = advanceData.GetQuickFilters();

            if (quickFilters != null && quickFilters.Any())
            {
                var newQuery = new QueryFilterSQL
                {
                    Method     = FilterMethod.And,
                    SubFilters = quickFilters,
                };
                if (query.Filter == null)
                {
                    query.Filter = newQuery;
                }
                else
                {
                    query.Filter.MergeFilter(newQuery);
                }
            }

            var result = query.Filter;

            return(result);
        }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> PostSelectData(JObject jsonData)
        {
            TransferObj result   = new TransferObj();
            dynamic     postData = ((dynamic)jsonData);
            FilterObj <AuNguoiDungVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <AuNguoiDungVm.Search> >();
            PagedObj <AU_NGUOIDUNG>          paged    = ((JObject)postData.paged).ToObject <PagedObj <AU_NGUOIDUNG> >();
            string       unitCode   = _service.GetCurrentUnitCode();
            string       maDonViCha = _service.GetParentUnitCode();
            QueryBuilder query      = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ()
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new AU_NGUOIDUNG().UnitCode),
                            Method   = FilterMethod.StartsWith,
                            Value    = maDonViCha
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new AU_NGUOIDUNG().TenNhanVien),
                            Method   = FilterMethod.Like,
                            Value    = filtered.Summary
                        }
                    },
                    Method = FilterMethod.And
                }
            };

            try
            {
                ResultObj <PagedObj <AU_NGUOIDUNG> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }

                result.Data = Mapper.Map <PagedObj <AU_NGUOIDUNG>, PagedObj <ChoiceObj> >
                                  (filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 7
0
        public IActionResult Index(string stuff, string subType, string productType, string price, string search, string priceFrom, string priceTo)
        {
            var viewModel = new ViewModel();

            try
            {
                var lstAllProduct = _context.Products.OrderByDescending(n => n.CRUDDate).ToList();
                foreach (var item in lstAllProduct)
                {
                    var imageObj = _context.ProductImages.FirstOrDefault(i => i.ProductId == item.Id && i.Index == 1);
                    if (imageObj == null)
                    {
                        imageObj = new ProductImage
                        {
                            Path = "img/content/product-04.jpg",
                        };
                    }
                    item.GImage = imageObj;
                }
                double priceFromNumb = 0;
                double priceToNumb   = 0;

                var priceFromCheck = double.TryParse(priceFrom, out priceFromNumb);
                var priceToCheck   = double.TryParse(priceTo, out priceToNumb);

                var filter = new FilterObj
                {
                    Stuff       = stuff,
                    Subtype     = subType,
                    ProductType = productType,
                    Price       = price,
                    Search      = search,
                    PriceFrom   = priceFromNumb,
                    PriceTo     = priceToNumb,
                };
                viewModel.allProducts        = GetLstProduct(filter, lstAllProduct);
                viewModel.allBanners         = lstAllProduct.Where(n => n.IsBestSelling == true).Take(10).ToList();
                viewModel.allProductTypes    = _context.ProductTypes.ToList();
                viewModel.allProductTypes    = _context.ProductTypes.ToList();
                viewModel.allSpecial         = lstAllProduct.Take(5).ToList();
                viewModel.allProductSubTypes = _context.ProductSubTypes.ToList();
                viewModel.allStuff           = _context.Products.GroupBy(n => n.Stuff).Select(n => n.Key).ToList();
                viewModel.BannerObj          = _context.Banners.FirstOrDefault();

                return(View(viewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Обновить историю входов пользователя в систему.
        /// </summary>
        private void HistRefresh()
        {
            if (dgvUser.Rows.Count == 0)
            {
                return;
            }
            string userID = dgvUser.SelectedRows[0].Cells["ID"].Value.ToString();
            string sql    = "SELECT ID, EntityID, ConnectionName, ComputerName, " +
                            " ComputerUserName, UserForm, UserID, SystemName, EnterDate " +
                            "FROM fbaEnterHist WHERE UserID = " + userID;
            var filter = new FilterObj();

            filter.FullQuerySQL = sql;
            sys.RefreshGrid(DirectionQuery.Remote, sgHist, filter);
        }
Ejemplo n.º 9
0
        public async Task <IHttpActionResult> PostQuery(JObject jsonData)
        {
            string _unitCode = _service.GetCurrentUnitCode();
            TransferObj <PagedObj <NvGiaoDichQuayVm.Dto> > result = new TransferObj <PagedObj <NvGiaoDichQuayVm.Dto> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvGiaoDichQuayVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvGiaoDichQuayVm.Search> >();

            filtered.OrderBy = "NgayPhatSinh";
            PagedObj <NvGiaoDichQuay> paged = ((JObject)postData.paged).ToObject <PagedObj <NvGiaoDichQuay> >();
            string       unitCode           = _service.GetCurrentUnitCode();
            QueryBuilder query = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ()
                {
                    Property = ClassHelper.GetProperty(() => new NvGiaoDichQuay().MaDonVi),
                    Method   = FilterMethod.StartsWith,
                    Value    = _unitCode
                },
                Orders = new List <IQueryOrder>
                {
                    new QueryOrder()
                    {
                        Field  = ClassHelper.GetPropertyName(() => new NvGiaoDichQuay().NgayPhatSinh),
                        Method = OrderMethod.DESC
                    }
                }
            };

            try
            {
                ResultObj <PagedObj <NvGiaoDichQuay> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }

                result.Data   = Mapper.Map <PagedObj <NvGiaoDichQuay>, PagedObj <NvGiaoDichQuayVm.Dto> >(filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 10
0
        public async Task <IHttpActionResult> PostPrint(JObject jsonData)
        {
            List <NvXuatKhacVm.Dto> result = new List <NvXuatKhacVm.Dto>();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvXuatKhacVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvXuatKhacVm.Search> >();
            PagedObj <NvVatTuChungTu>       paged    = ((JObject)postData.paged).ToObject <PagedObj <NvVatTuChungTu> >();
            string       unitCode = _service.GetCurrentUnitCode();
            QueryBuilder query    = new QueryBuilder
            {
                TakeAll = true,
                Filter  = new QueryFilterLinQ()
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().LoaiPhieu),
                            Method   = FilterMethod.EqualTo,
                            Value    = TypeVoucher.XKHAC.ToString()
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().UnitCode),
                            Method   = FilterMethod.EqualTo,
                            Value    = unitCode
                        }
                    },
                    Method = FilterMethod.And
                }
            };

            try
            {
                ResultObj <PagedObj <NvVatTuChungTu> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }

                result = Mapper.Map <List <NvVatTuChungTu>, List <NvXuatKhacVm.Dto> >(filterResult.Value.Data);
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 11
0
        public async Task <List <User> > GetUsers(FilterObj obj)
        {
            if (obj.UserId != null)
            {
                return(new List <User> {
                    await _context.User.FirstOrDefaultAsync(u => u.Id == obj.UserId)
                });
            }

            var users = await _context.User.AsNoTracking().
                        Where(u => (obj.Category == null || u.CategoryId == obj.Category) &&
                              (obj.StartDate == null || u.CreationTime >= obj.StartDate) &&
                              (obj.EndDate == null || u.CreationTime <= obj.EndDate))
                        .ToListAsync();

            return(users);
        }
Ejemplo n.º 12
0
        //Метод сборки фильтра желательно (но необязательно) должен называться так.
        public string MethodStaticFilter(Object FormRef, FilterObj filterIN) //FilterObj filterIN
        {
            this.FormRef = FormRef;                                          //Ссылка на форму, которая вызвала фильтр.
            string WHERE = " (1=1) ";

            if (cbID.Checked)
            {
                WHERE = WHERE + " AND (ObjectID = '" + tbID.Text + "') ";
            }
            if (cbNumber.Checked)
            {
                WHERE = WHERE + " AND (Number IN('" + tbNumber.Text + "')) ";
            }
            if (cbType.Checked)
            {
                WHERE = WHERE + " AND (contracttype = " + tbType.Text + ") ";
            }
            //sys.SM(WHERE);
            return(WHERE);
        }
Ejemplo n.º 13
0
        public async Task <string> Filter(FilterObj filter)
        {
            var loc = new List <Locations> {
            };

            if (filter.Neighbourhood == "All")
            {
                loc = await Context.Listings.Where(x => x.ReviewScoresRating > filter.Review && Convert.ToDouble(x.Price) < filter.Price).Select(x => new Locations {
                    Id = x.Id, Latitude = x.Latitude, Longitude = x.Longitude
                }).ToListAsync();
            }
            else
            {
                loc = await Context.Listings.Where(x => x.Neighbourhood == filter.Neighbourhood && x.ReviewScoresRating > filter.Review && Convert.ToDouble(x.Price) < filter.Price).Select(x => new Locations {
                    Id = x.Id, Latitude = x.Latitude, Longitude = x.Longitude
                }).ToListAsync();
            }
            string json = convertToGeoJson(loc);

            return(json);
        }
Ejemplo n.º 14
0
        public async Task <IHttpActionResult> PostQuery(JObject jsonData)
        {
            TransferObj <PagedObj <NvKiemKeVm.Dto> > result = new TransferObj <PagedObj <NvKiemKeVm.Dto> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvKiemKeVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvKiemKeVm.Search> >();

            filtered.OrderType = "DESC";
            filtered.OrderBy   = "NgayKiemKe";
            PagedObj <NvKiemKe> paged = ((JObject)postData.paged).ToObject <PagedObj <NvKiemKe> >();
            string       unitCode     = _serviceKK.GetCurrentUnitCode();
            QueryBuilder query        = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ()
                {
                    Property = ClassHelper.GetProperty(() => new NvKiemKe().UnitCode),
                    Method   = FilterMethod.EqualTo,
                    Value    = unitCode
                },
            };

            try
            {
                ResultObj <PagedObj <NvKiemKe> > filterResult = _serviceKK.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }
                result.Data   = Mapper.Map <PagedObj <NvKiemKe>, PagedObj <NvKiemKeVm.Dto> >(filterResult.Value);
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 15
0
 public async Task <string> Filter(FilterObj filter)
 {
     return(await _listingsRepository.Filter(filter));
 }
        private void Btnfilter_Click(object sender, RoutedEventArgs e)
        {
            string colName = "";
            Button btn     = sender as Button;
            ObservableCollection <FilterObj> fltcurrent;

            popExcel.PlacementTarget = btn;
            StackPanel sp = btn.Parent as StackPanel;

            foreach (var ch in sp.Children)
            {
                if (ch is TextBlock tb)
                {
                    colName = tb.Text;

                    break;
                }
            }


            Button button     = sender as Button;
            object wantedNode = button.FindName("FilterIcon");

            if (wantedNode is PackIcon)
            {
                wantedchild = wantedNode as PackIcon;

                wantedchilds.Add(wantedchild);
            }



            if (colName == "WBS Element")
            {
                colName = "WBSElement";
            }

            if (colName == "Product No")
            {
                colName = "ProductNo";
            }

            if (colName == "Item Desc")
            {
                colName = "ItemDescription";
            }

            if (colName == "Material No")
            {
                colName = "MatrialNo";
            }

            if (colName == "Qty Req")
            {
                colName = "QtyReq";
            }

            if (colName == "Unit")
            {
                colName = "UnitofMeasurment";
            }

            if (colName == "Purchasing Doc")
            {
                colName = "PurchasingDocument";
            }

            if (colName == "Purchase Date")
            {
                colName = "PurchaseOrderNo";
            }

            if (colName == "Unit Rate Price")
            {
                colName = "UnitRatePrice";
            }


            if (colName == "Net Order Price")
            {
                colName = "NetOrderPrice";
            }

            if (colName == "Supplier Name")
            {
                colName = "SupplierName";
            }


            applyfiltercolname = colName;



            fltcurrent = new ObservableCollection <FilterObj>();

            try
            {
                if (filters.ContainsKey(colName))
                {
                    filters.TryGetValue(colName, out fltcurrent);
                }
                else
                {
                    foreach (Product p in vdata.View)
                    {
                        string value = p.GetType().GetProperty(colName).GetValue(p, null).ToString();

                        if (value != null)
                        {
                            FilterObj f = new FilterObj()
                            {
                                Is_Check = false, Title = value
                            };

                            bool is_new = true;
                            foreach (FilterObj flt in fltcurrent)
                            {
                                if (flt.Title == value)
                                {
                                    is_new = false;
                                    break;
                                }
                            }
                            if (is_new)
                            {
                                fltcurrent.Add(f);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                lbfilter.ItemsSource = fltcurrent;

                if (!filters.ContainsKey(colName))
                {
                    filters.Add(colName, fltcurrent);
                }
            }


            popExcel.Uid    = colName;
            popExcel.IsOpen = true;
        }
Ejemplo n.º 17
0
        public async Task <IHttpActionResult> PostSelectData(JObject jsonData)
        {
            TransferObj <PagedObj <NvDatHang> > result = new TransferObj <PagedObj <NvDatHang> >();
            dynamic postData = ((dynamic)jsonData);
            FilterObj <NvPhieuDatHangNCCVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvPhieuDatHangNCCVm.Search> >();

            filtered.OrderBy   = "Ngay";
            filtered.OrderType = "DESC";
            PagedObj <NvDatHang> paged  = ((JObject)postData.paged).ToObject <PagedObj <NvDatHang> >();
            string       parentUnitCode = _service.GetParentUnitCode();
            QueryBuilder query          = new QueryBuilder
            {
                Take   = paged.ItemsPerPage,
                Skip   = paged.FromItem - 1,
                Filter = new QueryFilterLinQ
                {
                    SubFilters = new List <IQueryFilter>()
                    {
                        new QueryFilterLinQ
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().UnitCode),
                            Method   = FilterMethod.StartsWith,
                            Value    = parentUnitCode
                        },
                        new QueryFilterLinQ
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().TrangThai),
                            Method   = FilterMethod.EqualTo,
                            Value    = (int)OrderState.IsApproval
                        },
                        new QueryFilterLinQ
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().MaNhaCungCap),
                            Method   = FilterMethod.EqualTo,
                            Value    = filtered.AdvanceData.MaNhaCungCap
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().Loai),
                            Method   = FilterMethod.EqualTo,
                            Value    = (int)LoaiDatHang.NHACUNGCAP
                        },
                        new QueryFilterLinQ()
                        {
                            Property = ClassHelper.GetProperty(() => new NvDatHang().SoPhieuCon),
                            Method   = FilterMethod.Null,
                        }
                    },
                    Method = FilterMethod.And
                },
                Orders = new List <IQueryOrder>()
                {
                    new QueryOrder()
                    {
                        Field  = ClassHelper.GetPropertyName(() => new NvDatHang().ICreateDate),
                        Method = OrderMethod.DESC
                    }
                }
            };

            try
            {
                ResultObj <PagedObj <NvDatHang> > filterResult = _service.Filter(filtered, query);
                if (!filterResult.WasSuccessful)
                {
                    return(NotFound());
                }

                result.Data   = filterResult.Value;
                result.Status = true;
                return(Ok(result));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 18
0
        public async Task <ResultObj <PagedObj <TEntity> > > FilterAsync <TSearch>(FilterObj <TSearch> filtered, IQueryBuilder query = null) where TSearch : IDataSearch
        {
            query = query ?? new QueryBuilder();
            var advanceData = filtered.AdvanceData;

            if (!filtered.IsAdvance)
            {
                advanceData.LoadGeneralParam(filtered.Summary);
            }
            var filters = advanceData.GetFilters();

            if (filters.Count > 0)
            {
                var newQuery = new QueryFilterLinQ
                {
                    Method     = filtered.IsAdvance ? FilterMethod.And : FilterMethod.Or,
                    SubFilters = filters,
                };
                if (query.Filter == null)
                {
                    query.Filter = newQuery;
                }
                else
                {
                    query.Filter.MergeFilter(newQuery);
                }
            }
            var quickFilters = advanceData.GetQuickFilters();

            if (quickFilters != null && quickFilters.Any())
            {
                var newQuery = new QueryFilterLinQ
                {
                    Method     = FilterMethod.And,
                    SubFilters = quickFilters,
                };
                if (query.Filter == null)
                {
                    query.Filter = newQuery;
                }
                else
                {
                    query.Filter.MergeFilter(newQuery);
                }
            }
            // load order
            if (!string.IsNullOrEmpty(filtered.OrderBy))
            {
                query.OrderBy(new QueryOrder
                {
                    Field      = filtered.OrderBy,
                    MethodName = filtered.OrderType
                });
            }
            // at lease one order for paging
            if (query.Orders.Count == 0)
            {
                query.OrderBy(new QueryOrder {
                    Field = advanceData.DefaultOrder
                });
            }
            // query
            var result = new ResultObj <PagedObj <TEntity> >();

            try
            {
                var data = await QueryPagedAsync(query);

                result.Value = data;
                result.State = ResultState.Success;
            }
            catch (Exception ex)
            {
                result.SetException = ex;
            }
            return(result);
        }
Ejemplo n.º 19
0
 public async Task <ActionResult <List <User> > > GetUsers(FilterObj obj)
 {
     return(await _repository.GetUsers(obj));
 }
Ejemplo n.º 20
0
 ///Показ таблицы.
 private void RefreshGridForm(DirectionQuery direction, FBA.GridFBA dg, FilterObj filter)
 {
     sys.RefreshGrid(direction, dg, filter, tbGridInformation);
 }