Ejemplo n.º 1
0
        private bool Valid(getInventoryLevelsRequest request, ref string errorMessage)
        {
            bool isValidRequest = true;

            if (request.Request is null)
            {
                isValidRequest = false;
                errorMessage  += "999: General Error – Contact the System Service Provider";
            }
            else
            {
                if (request.Request.wsVersion != "1.2.1")
                {
                    isValidRequest = false;
                    errorMessage  += "115: wsVersion not found";
                }
                if (string.IsNullOrEmpty(request.Request.id))
                {
                    isValidRequest = false;
                    errorMessage  += "110: Authentication Credentials required";
                }
                if (string.IsNullOrEmpty(request.Request.password))
                {
                    isValidRequest = false;
                    errorMessage  += "110: Authentication Credentials required";
                }
                if (string.IsNullOrEmpty(request.Request.productID))
                {
                    isValidRequest = false;
                    errorMessage  += "200: ProductID not found";
                }
            }

            return(isValidRequest);
        }
Ejemplo n.º 2
0
        private bool Authenticated(getInventoryLevelsRequest request, ref string errorMessage)
        {
            using (var context = new Landau_PromoStandardsEntities())
            {
                var authQuery = context.Authentications.Where(x => x.UserId == request.Request.id).FirstOrDefault();

                if (!string.IsNullOrEmpty(authQuery.UserId))
                {
                    if (authQuery.Password.Equals(request.Request.password))
                    {
                        return(true);
                    }
                    else
                    {
                        errorMessage += "105: Authentication Credentials failed";
                        return(false);
                    }
                }
                else
                {
                    errorMessage += "100: ID (customerID) not found";
                    return(false);
                }
            }
        }
    public Reply getInventoryLevels(Request Request)
    {
        getInventoryLevelsRequest inValue = new getInventoryLevelsRequest();

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

        return(retVal.Reply);
    }
Ejemplo n.º 4
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);
        }
 getInventoryLevelsResponse InventoryService.getInventoryLevels(getInventoryLevelsRequest request)
 {
     return(base.Channel.getInventoryLevels(request));
 }