Ejemplo n.º 1
0
        public ActionResult GetSKUListByMain(string FilterType, int id_value)
        {
            List <ProductSKUList_Data> data = new List <ProductSKUList_Data>();

            if (FilterType == "salepage_id")
            {
                ProductSKUList store = ProductService.GetSKUListByMain(id_value);
                data = store.Data;
            }
            else if (FilterType == "shopCategoryId")
            {
                ProductCategoryViewModel pcvm = new ProductCategoryViewModel();
                pcvm.ShopCategoryId = id_value;
                ProductCategory pc = ProductService.GetSKUList(pcvm);
                data = pc.Data;
            }
            if (data != null)
            {
                return(Json(data));
            }
            else
            {
                return(Json(""));
            }
        }
Ejemplo n.º 2
0
        public static ProductSKUList GetSKUListByMain(int salepage_id)
        {
            var client  = new RestClient("https://apigw.qa.91dev.tw/ec/V1/SalePage/GetSKUListByMain");
            var request = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("Connection", "keep-alive");
            request.AddHeader("Content-Length", "21");
            request.AddHeader("Accept-Encoding", "gzip, deflate");
            request.AddHeader("Host", "apigw.qa.91dev.tw");
            request.AddHeader("Cache-Control", "no-cache");
            request.AddHeader("x-api-key", keyValue);
            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("undefined", "{\r\n  \"id\": " + salepage_id + "\r\n}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            ProductSKUList store = Newtonsoft.Json.JsonConvert.DeserializeObject <ProductSKUList>(response.Content);

            return(store);
        }
Ejemplo n.º 3
0
        public IHttpActionResult branchStockStatusFilter(InputBranchStockStatusReportModel inputmodel)
        {
            List <string> BranchIdList;   // = new List<string>();
            List <string> ProductSKUList; // = new List<string>();
            List <string> StyleSKUList;   // = new List<string>();

            var moddel = getProcessingData(inputmodel, out BranchIdList, out ProductSKUList, out StyleSKUList);

            Dictionary <int, int>          branchlist = new Dictionary <int, int>();
            List <BranchStockStatusReport> result     = new List <BranchStockStatusReport>();
            var ProductList = db.Products.Where(x => x.IsActive == true && x.StockInventories.Any(y => y.IsActive ?? false) == true && x.StockBranchInventories.Any(y => y.IsActive ?? false) == true)

                              .Include(i => i.Color)
                              .Include(i => i.Template1)
                              .Include(i => i.StockInventories)
                              .Include(i => i.StockBranchInventories)
                              .Include(i => i.StockBranchInventories.Select(y => y.Branch))
                              //.ToList()
            ;
            var ptemp = ProductList.ToList();

            if (ProductSKUList.Count > 0)
            {
                ProductList = ProductList.Where(x => ProductSKUList.Contains(x.ProductSKU));
                ptemp       = ProductList.ToList();
            }
            if (StyleSKUList.Count > 0)
            {
                ProductList = ProductList.Where(x => StyleSKUList.Contains(x.StyleSKU));
                ptemp       = ProductList.ToList();
            }

            var products         = ProductList.ToList();
            var branchSearchlist = db.Branches.Where(x => x.IsActive == true);
            var btemp            = branchSearchlist.ToList();

            if (BranchIdList.Count > 0)
            {
                branchSearchlist = branchSearchlist.Where(x => BranchIdList.Contains(x.BranchCode));
                btemp            = branchSearchlist.ToList();
            }


            var branches = branchSearchlist.OrderBy(o => o.Id).ToList();

            branches.ForEach(x => branchlist.Add(x.Id, 0));

            var modellist = products.Where(x => x.StockBranchInventories != null && x.StockBranchInventories.Count > 0).ToList();

            foreach (var item in modellist)
            {
                Dictionary <int, int>   branch = new Dictionary <int, int>();
                BranchStockStatusReport model  = new BranchStockStatusReport();
                var Branches = item.StockBranchInventories.Where(x => x.Branch.IsActive == true).Select(s => s.Branch).ToList();

                model.Product       = item.ProductSKU + " " + item.StyleSKU + " " + item.ShortDescription;
                model.Color         = item.Color?.Code + " " + item.Color?.ColorShort;
                model.CostPrice     = item.CostPrice ?? 0;
                model.OriginalPrice = item.ActualSellingPrice ?? 0;
                var sumQunatity  = SumQuantityInventory(item.StockBranchInventories.ToList(), out branch);
                var sumQuantity2 = SumQuantityInventory(item.StockInventories.ToList());
                model.TotalQuantiy      = sumQunatity + sumQuantity2;
                model.WarehoustQuantity = sumQuantity2;
                model.MarkdownTemplate  = item.Template1?.Name;
                model.BranchId          = new Dictionary <int, int>();
                foreach (var bran in branchlist)
                {
                    if (branch.ContainsKey(bran.Key))
                    {
                        var value = branch[bran.Key];
                        model.BranchId.Add(bran.Key, value);
                    }
                    else
                    {
                        model.BranchId.Add(bran.Key, bran.Value);
                    }
                }

                // model.TotalQuantiy = "";
                result.Add(model);
            }
            return(Ok(result));
        }