public Reply getInventoryLevels(Request Request)
    {
        getInventoryLevelsRequest inValue = new getInventoryLevelsRequest();

        inValue.Request = Request;
        getInventoryLevelsResponse retVal = ((InventoryService)(this)).getInventoryLevels(inValue);

        return(retVal.Reply);
    }
예제 #2
0
        public getInventoryLevelsResponse getInventoryLevels(getInventoryLevelsRequest request)
        {
            getInventoryLevelsResponse response = new getInventoryLevelsResponse();
            string errorMessage = string.Empty;

            if (Valid(request, ref errorMessage))
            {
                if (Authenticated(request, ref errorMessage))
                {
                    string   productid    = request.Request.productID;
                    string[] filterColors = request.Request.FilterColorArray;
                    string[] filterSize   = request.Request.FilterSizeArray;

                    List <ReplyProductVariationInventory> productVariations   = new List <ReplyProductVariationInventory>();
                    List <ReplyProductCompanionInventory> productAlternatives = new List <ReplyProductCompanionInventory>();

                    //get available to ship
                    //filter based on filter values
                    using (var context = new LAN_AX2012_PRODEntities())
                    {
                        //get color codes
                        var colorQuery = context.LAN_VW_COLORDATA
                                         .Where(x => x.ITEMID == productid && filterColors.Contains(x.NAME))
                                         .GroupBy(y => y.InventColorId)
                                         .ToList();

                        List <string> colorCodes = colorQuery.Select(x => x.Key).ToList();

                        var availableQuery = context.LAN_VW_GETAVAILABLETOSHIP
                                             .Where(x => x.ITEMID == productid);

                        if (availableQuery.Count() == 0)
                        {
                            errorMessage += "200: ProductID not found";

                            response.Reply = new Reply
                            {
                                errorMessage = errorMessage
                            };

                            return(response);
                        }

                        if (filterColors.Length > 0)
                        {
                            //check colors
                            availableQuery = availableQuery.Where(x => filterColors.Contains(x.INVENTCOLORID));
                            if (availableQuery.Count() == 0)
                            {
                                errorMessage += "205: ProductColor not found";

                                response.Reply = new Reply
                                {
                                    errorMessage = errorMessage
                                };

                                return(response);
                            }
                        }

                        if (filterSize.Length > 0)
                        {
                            //check sizes
                            availableQuery = availableQuery.Where(x => filterSize.Contains(x.INVENTSIZEID));
                            if (availableQuery.Count() == 0)
                            {
                                errorMessage += "210: ProductSize not found";

                                response.Reply = new Reply
                                {
                                    errorMessage = errorMessage
                                };

                                return(response);
                            }
                        }
                        var sizeLength  = filterSize.Length;
                        var colorLength = filterColors.Length;

                        var skuQuery = context.LAN_VW_SKUMASTERDATA
                                       .Where(x => x.ITEMID == productid &&
                                              (sizeLength == 0 || filterSize.Contains(x.INVENTSIZEID)) &&
                                              (colorLength == 0 || filterColors.Contains(x.INVENTCOLORID)))
                                       .ToList();


                        foreach (var prod in availableQuery)
                        {
                            var sku = skuQuery.Where(x => x.ITEMID == prod.ITEMID &&
                                                     x.INVENTSIZEID == prod.INVENTSIZEID &&
                                                     x.INVENTCOLORID == prod.INVENTCOLORID)
                                      .First();

                            productVariations.Add(new ReplyProductVariationInventory
                            {
                                partID             = productid,
                                partDescription    = sku.ItemName,
                                partBrand          = sku.DATAAREAID,
                                priceVariance      = string.Empty,
                                quantityAvailable  = prod.GetAvailToShipQty.ToString(),
                                attributeColor     = prod.INVENTCOLORID,
                                attributeSize      = prod.INVENTSIZEID,
                                attributeSelection = string.Empty,
                                validTimestamp     = DateTime.Now,
                                entryType          = "exact"
                            });

                            switch (sku.SUNTAFITEMSTATUS)
                            {
                            case "DIS":
                                productVariations.Last().customProductMessage = "Discontinued: Supply limited";
                                break;

                            case "HIS":
                                productVariations.Last().customProductMessage = "No longer available";
                                break;

                            case "ACT":
                                productVariations.Last().customProductMessage = "Active";
                                break;

                            case "WSL":
                                productVariations.Last().customProductMessage = "While Supply Lasts";
                                break;

                            default:
                                productVariations.Last().customProductMessage = string.Empty;
                                break;
                            }
                        }
                    }



                    response.Reply = new Reply
                    {
                        productID = productid,
                        ProductVariationInventoryArray = productVariations.ToArray()
                    };
                }
                else
                {
                    response.Reply = new Reply
                    {
                        errorMessage = errorMessage
                    };
                }
            }
            else
            {
                response.Reply = new Reply
                {
                    errorMessage = errorMessage
                };
            }

            return(response);
        }