コード例 #1
0
        public PagesListResult <Customer> GetCustomers(string filter, int?pageNumber, int?pageSize, bool ShoppingArea = false)
        {
            var itemsPerPage   = pageSize.HasValue ? pageSize.Value : 50;
            var currentPageNum = pageNumber.HasValue ? pageNumber.Value : 1;

            ApplicationUser user;
            int             ShoppingAreaId = 0;

            if (ShoppingArea)
            {
                user = _context.Users.Single(x => x.UserName == HttpContext.User.Identity.Name);
                if (user != null)
                {
                    UserMeta userMeta = _context.UserMeta.FirstOrDefault(u => u.Id == user.UserMetaId);

                    ShoppingAreaId = (int)userMeta.ShoppingAreaId;
                }

                if (ShoppingAreaId == 0)
                {
                    ShoppingArea = false;
                }
                ;
            }


            var qry = _context.Customers.AsNoTracking().AsQueryable();

            if (ShoppingArea)
            {
                qry = _context.CustomerShoppingArea.AsNoTracking()
                      .Where(c => c.ShoppingAreaId == ShoppingAreaId && c.UpdateStatus != 2)
                      //.OrderBy(c => c.Customer.Descr)
                      .Include(c => c.Customer)
                      .Select(c => c.Customer);

                if (!string.IsNullOrWhiteSpace(filter))
                {
                    qry = qry.Where(c => c.Descr.StartsWith(filter));
                }

                qry = qry.OrderBy(c => c.Descr);
            }
            else
            {
                qry = _context.Customers.AsNoTracking().AsQueryable();
                if (!string.IsNullOrWhiteSpace(filter))
                {
                    qry = qry.Where(c => c.Descr.StartsWith(filter));
                }

                qry = qry.OrderBy(c => c.Descr);
            }

            return(PagesListResult <Customer> .Create(qry, currentPageNum, itemsPerPage));
        }
コード例 #2
0
ファイル: OrdersController.cs プロジェクト: cfgsoft/BeerStore
        public PagesListResult <Order> GetOrders(string filter, int?pageNumber, int?pageSize)
        {
            var itemsPerPage   = pageSize.HasValue ? pageSize.Value : 50;
            var currentPageNum = pageNumber.HasValue ? pageNumber.Value : 1;

            string UserId = GetUserId();

            var qry = _context.Orders.AsNoTracking().AsQueryable();

            qry = qry.Where(c => c.UserId == UserId)
                  .OrderByDescending(c => c.Date)
                  .Include(o => o.Customer)
                  .Include(o => o.Outlet)
                  .Include(o => o.Warehouse);

            return(PagesListResult <Order> .Create(qry, currentPageNum, itemsPerPage));
        }
コード例 #3
0
        public PagesListResult <Product> GetProducts(int categoryId, string filter, int?pageNumber, int?pageSize)
        {
            var itemsPerPage   = pageSize.HasValue ? pageSize.Value : 50;
            var currentPageNum = pageNumber.HasValue ? pageNumber.Value : 1;

            var qry = _context.Products.AsNoTracking().AsQueryable();

            qry = qry.Where(c => c.CategoryId == categoryId);


            if (!string.IsNullOrWhiteSpace(filter))
            {
                qry = qry.Where(c => c.Descr.StartsWith(filter));
            }

            qry = qry.OrderBy(c => c.Descr);

            return(PagesListResult <Product> .Create(qry, currentPageNum, itemsPerPage));
        }
コード例 #4
0
        /// <summary>
        /// List page-related API entry points.
        /// </summary>
        /// <param name="fullyQualifyResults">If set to TRUE, returns fully qualified URI. Otherwise the result is only the final segment of the URI. (Note that this is not a parameter for the REST API endpoint)</param>
        /// <returns>List of URI strings. Will be Non-NULL + empty list in case of problems.</returns>
        public List <string> GetEndpoints(bool fullyQualifyResults = true)
        {
            string        responseJson = GET("page");
            List <string> results      = new List <string>();

            if (!string.IsNullOrWhiteSpace(responseJson))
            {
                PagesListResult result = JsonSerializer.Deserialize <PagesListResult>(responseJson);
                results = result.Items;

                if (fullyQualifyResults)
                {
                    for (int i = 0; i < result.Items.Count; i++)
                    {
                        results[i] = $"{ENDPOINT_BASE_URI}/page/{results[i]}";
                    }
                }
            }

            return(results);
        }
コード例 #5
0
        public PagesListResult <Department> GetDepartments(string filter, int?pageNumber, int?pageSize, bool showIsMark = false)
        {
            var itemsPerPage   = pageSize.HasValue ? pageSize.Value : 50;
            var currentPageNum = pageNumber.HasValue ? pageNumber.Value : 1;

            var qry = _context.Departments.AsNoTracking().AsQueryable();

            if (!string.IsNullOrWhiteSpace(filter))
            {
                qry = qry.Where(c => c.Descr.StartsWith(filter));
            }

            if (!showIsMark)
            {
                qry = qry.Where(c => c.IsMark == false);
            }

            qry = qry.OrderBy(c => c.Descr);

            return(PagesListResult <Department> .Create(qry, currentPageNum, itemsPerPage));
        }