Esempio n. 1
0
        /// <summary>
        /// Creates delegate of PostProductList call
        /// </summary>
        /// <param name="productQuery">ProductQueryModel - defines product query parameters</param>
        /// <param name="login">user login</param>
        /// <param name="getTokenFunc">get bearer token delegate</param>
        /// <returns>PostProductList delegate</returns>
        public Func <IObservable <IList <ProductModel> > > PostProductListFunc(
            ProductQueryModel productQuery, string login, Func <string> getTokenFunc)
        {
            IObservable <IList <ProductModel> > PostProductListDelegate() =>
            PostProductList(productQuery, login, getTokenFunc());

            return(PostProductListDelegate);
        }
 private OrderQueryModel MapQueryModel(OrderModel order, ProductQueryModel product, ServiceMethodQueryModel serviceMethod)
 {
     return(new OrderQueryModel
     {
         Id = order.Id,
         Additions = order.Additions,
         PreparationMethod = order.PreparationMethod,
         CustomerEmail = order.CustomerEmail,
         CustomerName = order.CustomerName,
         CustomerPhoneNumber = order.CustomerPhoneNumber,
         Product = product,
         ServiceMethod = serviceMethod
     });
 }
        public async Task <JsonResult> Search([FromBody] ProductQueryModel model)
        {
            var products      = _productService.Search(model.TypeAll, model.TypeId, model.PName, model.PageIndex.Value, model.PageSize.Value);
            var productModels = _mapper.Map <List <ProductListModel> >(products.ToList());
            var result        = new BaseListResultModel()
            {
                TotalPages   = products.TotalPages,
                TotalItems   = products.TotalCount,
                CurrentPage  = products.PageIndex,
                ItemsPerPage = products.PageSize,
                ContentList  = productModels
            };

            return(SucessResult(result));
        }
Esempio n. 4
0
        public async Task <IActionResult> Get(ProductQueryModel model)
        {
            var user = await _userService.GetUser(User);

            var result = await _productService.GetProductsAsync(new ProductQuery()
            {
                Page       = model.Page,
                PageSize   = model.PageSize,
                CategoryId = model.CategoryId,
                SearchText = model.SearchText,
                UserId     = user.Id
            });

            return(Ok(result));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> PostProduct(ProductQueryModel pqm)
        {
            List <Product> products = new List <Product>();


            if (string.IsNullOrEmpty(pqm.ProductName) && string.IsNullOrEmpty(pqm.ProductCode))
            {
                return(NotFound());
            }
            else
            {
                if (string.IsNullOrEmpty(pqm.ProductCode))
                {
                    products = await(from p in db.Products.Include(p => p.Partner) where p.ProductName.Contains(pqm.ProductName) select p).ToListAsync();
                }
                else
                if (string.IsNullOrEmpty(pqm.ProductName))
                {
                    products = await(from p in db.Products.Include(p => p.Partner) where p.ProductCode.Contains(pqm.ProductCode) select p).ToListAsync();
                }
                else
                {
                    products = await(from p in db.Products.Include(p => p.Partner) where p.ProductCode.Contains(pqm.ProductCode) && p.ProductName.Contains(pqm.ProductName) select p).ToListAsync();
                }
            }

            if (products.Count == 0)
            {
                return(NotFound());
            }
            var pvms = products.Select(v => new ProductViewModel
            {
                Id          = v.Id,
                Name        = v.ProductName,
                ProductCode = v.ProductCode,
                BeginDate   = v.ValidStartDate,
                EndDate     = v.ValidEndDate,
                Price       = v.Price,
                Provider    = v.Partner.Name,
                Type        = v.ProductType
            });



            return(Ok(pvms));
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> PostComboProduct(ProductQueryModel pqm)
        {
            List <ComboProduct> comboProducts = new List <ComboProduct>();


            if (string.IsNullOrEmpty(pqm.ProductName) && string.IsNullOrEmpty(pqm.ProductCode))
            {
                return(NotFound());
            }
            else
            {
                if (string.IsNullOrEmpty(pqm.ProductCode))
                {
                    comboProducts = await(from p in db.ComboProducts where p.ComboName.Contains(pqm.ProductName) select p).ToListAsync();
                }
                else
                if (string.IsNullOrEmpty(pqm.ProductName))
                {
                    comboProducts = await(from p in db.ComboProducts where p.ComboCode.Contains(pqm.ProductCode) select p).ToListAsync();
                }
                else
                {
                    comboProducts = await(from p in db.ComboProducts where p.ComboCode.Contains(pqm.ProductCode) && p.ComboName.Contains(pqm.ProductName) select p).ToListAsync();
                }
            }

            if (comboProducts.Count == 0)
            {
                return(NotFound());
            }
            var pvms = comboProducts.Select(v => new ProductViewModel
            {
                Id          = v.Id,
                Name        = v.ComboName,
                ProductCode = v.ComboCode,
                BeginDate   = v.ValidStartDate,
                EndDate     = v.ValidEndDate,
                Price       = v.Price,
                Provider    = "套餐",
                Type        = ProductType.Combo
            });

            return(Ok(pvms));
        }
        public async Task <DataTables <ProductDTO> > GetProductsAsync(ProductQueryModel model)
        {
            var query = new GetProductsQuery
            {
                PageSize      = model.PageSize,
                PageIndex     = model.PageIndex,
                OrderBy       = model.OrderBy,
                Draw          = model.Draw,
                Keyword       = model.Keyword,
                SortDirection = model.SortDirection,
                Status        = model.Status
            };

            query.SetContext(User.Identity);

            var plist = await ProductDF.GetProductsAsync(query).ConfigureAwait(false);

            return(new DataTables <ProductDTO>(query.Draw, plist));
        }
Esempio n. 8
0
        public async Task <IList <ProductEntity> > Query(ProductQueryModel model)
        {
            //分页
            var paging = model.Paging();

            var query = Db.Find();

            query.WhereIf(model.Title.NotNull(), m => m.Title.Contains(model.Title));

            //设置默认排序
            if (!paging.OrderBy.Any())
            {
                query.OrderByDescending(m => m.Id);
            }

            var list = await query.LeftJoin <AccountEntity>((x, y) => x.CreatedBy == y.Id)
                       .Select((x, y) => new { x, Creator = y.Name })
                       .PaginationAsync(paging);

            model.TotalCount = paging.TotalCount;
            return(list);
        }
        public ActionResult ProductSys(long?productId, long?brandId, long?manufacturerId, string key)
        {
            var user      = CurrentUser;
            var pageIndex = Request["pageIndex"].AsInt(1);
            var pageSize  = Request["pageSize"].AsInt(20);

            ViewData["UserId"]       = user.UserId;
            ViewData["manugacturer"] = ManufacturersSvr.Instance.GetManufatuer();
            var queryModel = new ProductQueryModel
            {
                ProductId      = productId,
                BrandId        = brandId,
                ManufacturerId = manufacturerId,
                CNNameLike     = key ?? null,
                Index          = pageIndex,
                Size           = pageSize
            };

            using (var db = new MbContext())
            {
                var models = db.Product
                             .Where(queryModel)
                             .ToList();
                queryModel.Data = models.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                var manufacturerIds = models.Select(x => x.ManufacturerId).ToArray();
                queryModel.ManufacturerDic = db.Manufacturer
                                             .Where(x => manufacturerIds.Contains(x.ManufacturerId))
                                             .ToLookup(x => x.ManufacturerId)
                                             .ToDictionary(x => x.Key, x => x.First());
                var brandIds = models.Select(x => x.BrandId).ToArray();
                queryModel.BrandDic = db.Brand
                                      .Where(x => brandIds.Contains(x.BrandId))
                                      .ToLookup(x => x.BrandId)
                                      .ToDictionary(x => x.Key, x => x.First());
                queryModel.Count = models.Count;
                return(View(queryModel));
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Product list with query endpoint
 /// Makes a POST call to IMobileService - /api/Products/list
 /// </summary>
 /// <param name="productQuery">ProductQueryModel - defines product query parameters</param>
 /// <param name="login">user login</param>
 /// <param name="token">bearer token</param>
 /// <returns>IObservable&lt;IList&lt;ProductModel&gt;&gt;</returns>
 public IObservable <IList <ProductModel> > PostProductList(ProductQueryModel productQuery, string login,
                                                            string token)
 {
     return(_mobileService.PostProductList(productQuery, FormatAuthHeader(login, token)));
 }
 public void OnGet(string id)
 {
     Product = _productQuery.GetProductDetails(id);
 }