Beispiel #1
0
        public JsonResult InventoryProducts(string sorting, string filter, int skip, int take, int pageSize, int page)
        {
            var filtersObject         = JsonConvert.DeserializeObject <FiltersModel>(filter ?? "");
            var hasFilterProviderName = string.IsNullOrWhiteSpace(filter) || filtersObject == null ? false : filtersObject.filters.Any(f => f.field == "ProviderName");
            var providerNameFilter    = string.Empty;

            if (hasFilterProviderName)
            {
                var filterItem = filtersObject.filters.First(f => f.field == "ProviderName");
                providerNameFilter = filterItem.value;
                filtersObject.filters.Remove(filterItem);
                filter = JsonConvert.SerializeObject(filtersObject);
                if (!filtersObject.filters.Any())
                {
                    filter = string.Empty;
                }
            }

            var pr = db.Products
                     .Where(p =>
                            !hasFilterProviderName ||
                            (
                                hasFilterProviderName &&
                                p.Provider.BusinessName.Contains(providerNameFilter)
                            )
                            )
                     .Where(p => p.Stocks.Any(s => s.StockQuantity > 0))
                     .Include(p => p.Provider)
                     .OrderBy(p => p.Code);

            var result = GridService.GetData(pr,
                                             sorting,
                                             filter,
                                             skip,
                                             take,
                                             pageSize,
                                             page);
            var products = result
                           .Data
                           .ToList()
                           .Select(p => GetProductItemModel(p));
            var count = result.Count;

            return(Json(new { total = count, data = products }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public JsonResult Products(string sorting, string filter, int skip, int take, int pageSize, int page)
        {
            var result = GridService.GetData(db.Products
                                             .Include(p => p.Category)
                                             .OrderBy(p => p.Code),
                                             sorting,
                                             filter,
                                             skip,
                                             take,
                                             pageSize,
                                             page);
            var products = result
                           .Data
                           .ToList()
                           .Select(p => GetProductItemModel(p));
            var count = result.Count;

            return(Json(new { total = count, data = products }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public JsonResult Orders(string sorting, string filter, int skip, int take, int pageSize, int page)
        {
            var filtersObject         = JsonConvert.DeserializeObject <FiltersModel>(filter ?? "");
            var hasFilterProviderName = string.IsNullOrWhiteSpace(filter) || filtersObject == null ? false : filtersObject.filters.Any(f => f.field == "ProviderName");
            var providerNameFilter    = string.Empty;

            if (hasFilterProviderName)
            {
                var filterItem = filtersObject.filters.First(f => f.field == "ProviderName");
                providerNameFilter = filterItem.value;
                filtersObject.filters.Remove(filterItem);
                filter = JsonConvert.SerializeObject(filtersObject);
                if (!filtersObject.filters.Any())
                {
                    filter = string.Empty;
                }
            }
            var result = GridService.GetData(db.PurchaseOrders.Where(p => p.PurchaseOrderStatu.Name.ToUpper() != "DONE").OrderByDescending(i => i.Id),
                                             sorting,
                                             filter,
                                             skip,
                                             take,
                                             pageSize,
                                             page);

            var orders = result
                         .Data
                         .ToList()
                         .Select(i => GetOrderItemModel(i));
            var count = result.Count;

            if (hasFilterProviderName)
            {
                orders = orders.Where(i =>
                                      Regex.Match(i.ProviderName.Trim().ToLower(),
                                                  providerNameFilter.Trim().ToLower()).Success);
            }

            return(Json(new { total = count, data = orders }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public JsonResult Invoices(string sorting, string filter, int skip, int take, int pageSize, int page)
        {
            var filtersObject        = JsonConvert.DeserializeObject <FiltersModel>(filter ?? "");
            var hasFilterCLientName  = string.IsNullOrWhiteSpace(filter) || filtersObject == null ? false : filtersObject.filters.Any(f => f.field == "ClientName");
            var hasFilterPaymentType = string.IsNullOrWhiteSpace(filter) || filtersObject == null ? false : filtersObject.filters.Any(f => f.field == "PaymentType");

            var clientNameFilter  = string.Empty;
            var paymentTypeFilter = string.Empty;

            if (hasFilterCLientName)
            {
                var filterItem = filtersObject.filters.First(f => f.field == "ClientName");
                clientNameFilter = filterItem.value;
                filtersObject.filters.Remove(filterItem);
                filter = JsonConvert.SerializeObject(filtersObject);
                if (!filtersObject.filters.Any())
                {
                    filter = string.Empty;
                }
            }

            if (hasFilterPaymentType)
            {
                var filterItem = filtersObject.filters.First(f => f.field == "PaymentType");
                paymentTypeFilter = filterItem.value;
                filtersObject.filters.Remove(filterItem);
                filter = JsonConvert.SerializeObject(filtersObject);
                if (!filtersObject.filters.Any())
                {
                    filter = string.Empty;
                }
            }

            //if (hasFilterCLientName)
            //{
            //    invoices = invoices.Where(i =>
            //        Regex.Match(i.ClientName.Trim().ToLower(),
            //        clientNameFilter.Trim().ToLower()).Success);
            //    count = invoices.Count();
            //}

            var result = GridService.GetData(db.Invoices
                                             .Where(i => !hasFilterCLientName || (hasFilterCLientName && (i.Client.FirstName.Contains(clientNameFilter) || i.Client.MiddleName.Contains(clientNameFilter) || i.Client.LastName.Contains(clientNameFilter))))
                                             .Where(i => !hasFilterPaymentType ||
                                                    (hasFilterPaymentType &&
                                                     i.PaymentType.Name.Contains(paymentTypeFilter)
                                                    ))
                                             .OrderByDescending(i => i.Id),
                                             sorting,
                                             filter,
                                             skip,
                                             take,
                                             pageSize,
                                             page);
            var invoices = result
                           .Data
                           .ToList()
                           .Select(i => GetInvoiceItemModel(i));
            var count = result.Count;

            return(Json(new { total = count, data = invoices }, JsonRequestBehavior.AllowGet));
        }