public void UpdateTag(Tag tag)
        {
            Tag targetTag = context.Tags.Find(tag.TagID);

            if (targetTag != null)
            {
                targetTag.TagName = tag.TagName;
            }
        }
Exemple #2
0
 public bool ContainsTag(Tag tag)
 {
     return Product.HasTag(tag);
 }
 public void InsertTag(Tag tag)
 {
     context.Tags.Add(tag);
 }
Exemple #4
0
 public bool HasTag(Tag tag)
 {
     if (Tags == null) return false;
     return (Tags.Where(t => object.Equals(tag.TagName, t.TagName)).Count() >= 1) ? true : false;
 }
Exemple #5
0
        public void AddTag(Tag tag)
        {
            if (Tags == null)
            {
                Tags = new HashSet<Tag>();
            }

            Tags.Add(tag);

            if (tag.Products == null)
            {
                tag.Products = new HashSet<Product>();
            }

            tag.Products.Add(this);
        }
Exemple #6
0
 public UserTag(AppUser user, Tag tag)
 {
     this.AppUser = user;
     this.Tag = tag;
 }
Exemple #7
0
        // using a Steam App ID, queries the storefront API to get information about the product and build the listing object
        // listings sent to this method should be persisted to prevent looping behavior
        private void BuildListingWithAppID(Listing listing, int appId)
        {
            if (listing.ListingID == 0)
            {
                throw new Exception("The listing was not persisted!");
            }
            if (listing.Product == null)
            {
                throw new Exception("A valid product object was not added to the listing object!");
            }

            ProductDetail productDetail = listing.Product.ProductDetail ?? new ProductDetail();

            if (listing.Product.ProductDetail == null)
            {
                listing.Product.AddProductDetail(productDetail);
            }

            string url = String.Format("http://store.steampowered.com/api/appdetails?appids={0}", listing.Product.AppID);

            string result = new System.Net.WebClient().DownloadString(url);

            JObject jsonResult = JObject.Parse(result);

            string appID = listing.Product.AppID.ToString();

            if (jsonResult == null || jsonResult[appID] == null || jsonResult[appID]["data"] == null)
            {
                return;
            }

            JToken appData = jsonResult[appID]["data"];
            int baseAppID = 0;

            //get all the product details from the jtoken
            productDetail.AppID = (appData["steam_appid"].IsNullOrEmpty()) ? 0 : (int)appData["steam_appid"];
            productDetail.ProductType = (string)appData["type"] ?? "";
            productDetail.ProductName = (string)appData["name"] ?? "";
            listing.ListingName = (String.IsNullOrEmpty(productDetail.ProductName) ? listing.ListingName : productDetail.ProductName);

            productDetail.AgeRequirement = (appData["required_age"].IsNullOrEmpty()) ? 0 : (int)appData["required_age"];
            productDetail.DetailedDescription = (string)appData["detailed_description"] ?? "";

            if (!appData["dlc"].IsNullOrEmpty())
            {
                productDetail.DLCAppIDs = appData["dlc"].Select(d => (int)d).ToArray();
            }

            productDetail.AboutTheGame = (string)appData["about_the_game"] ?? "";

            if (!appData["fullgame"].IsNullOrEmpty())
            {
                productDetail.BaseProductName = (string)appData["fullgame"]["name"] ?? "";
                baseAppID = (appData["fullgame"]["appid"].IsNullOrEmpty()) ? 0 : (int)appData["fullgame"]["appid"];
            }

            productDetail.SupportedLanguages = (string)appData["supported_languages"] ?? "";
            productDetail.HeaderImageURL = (string)appData["header_image"] ?? "";
            productDetail.ProductWebsite = (string)appData["website"] ?? "";

            if (!appData["pc_requirements"].IsNullOrEmpty())
            {
                productDetail.PCMinimumRequirements = (string)appData["pc_requirements"]["minimum"] ?? "";
                productDetail.PCRecommendedRequirements = (string)appData["pc_requirements"]["recommended"] ?? "";
            }

            if (!appData["mac_requirements"].IsNullOrEmpty())
            {
                productDetail.MacMinimumRequirements = (string)appData["mac_requirements"]["minimum"] ?? "";
                productDetail.MacRecommendedRequirements = (string)appData["mac_requirements"]["recommended"] ?? "";
            }

            if (!appData["linux_requirements"].IsNullOrEmpty())
            {
                productDetail.LinuxMinimumRequirements = (string)appData["linux_requirements"]["minimum"] ?? "";
                productDetail.LinuxRecommendedRequirements = (string)appData["linux_requirements"]["recommended"] ?? "";
            }

            if (!appData["developers"].IsNullOrEmpty())
            {
                productDetail.Developers = appData["developers"].Select(d => (string)d).ToArray();
            }

            if (!appData["publishers"].IsNullOrEmpty())
            {
                productDetail.Publishers = appData["publishers"].Select(d => (string)d).ToArray();
            }

            if (!appData["demos"].IsNullOrEmpty())
            {
                productDetail.DemoAppID = (appData["demos"][0]["appid"].IsNullOrEmpty()) ? 0 : (int)appData["demos"][0]["appid"];
                productDetail.DemoRestrictions = (string)appData["demos"][0]["description"] ?? "";
            }

            if (!appData["price_overview"].IsNullOrEmpty())
            {
                productDetail.FinalPrice = (appData["price_overview"]["final"].IsNullOrEmpty()) ? 0 : (int)appData["price_overview"]["final"];
                productDetail.InitialPrice = (appData["price_overview"]["initial"].IsNullOrEmpty()) ? 0 : (int)appData["price_overview"]["initial"];
                productDetail.CurrencyType = (string)appData["price_overview"]["currency"] ?? "";
            }

            if (!appData["packages"].IsNullOrEmpty())
            {
                productDetail.PackageIDs = appData["packages"].Select(d => (int)d).ToArray();
            }

            if (!appData["platforms"].IsNullOrEmpty())
            {
                productDetail.AvailableOnPC = (appData["platforms"]["windows"].IsNullOrEmpty()) ? true : (bool)appData["platforms"]["windows"];
                productDetail.AvailableOnMac = (appData["platforms"]["mac"].IsNullOrEmpty()) ? false : (bool)appData["platforms"]["mac"];
                productDetail.AvailableOnLinux = (appData["platforms"]["linux"].IsNullOrEmpty()) ? false : (bool)appData["platforms"]["linux"];
            }

            if (!appData["metacritic"].IsNullOrEmpty())
            {
                productDetail.MetacriticScore = (appData["metacritic"]["score"].IsNullOrEmpty()) ? 0 : (int)appData["metacritic"]["score"];
                productDetail.MetacriticURL = (string)appData["metacritic"]["url"] ?? "";
            }

            if (!appData["genres"].IsNullOrEmpty())
            {
                JArray jGenres = (JArray)appData["genres"];
                List<string> genresList = new List<string>();

                for (int i = 0; i < jGenres.Count; i++)
                {
                    genresList.Add((string)jGenres[i]["description"]);
                }

                string[] genres = genresList.ToArray();

                if (genres != null)
                {
                    for (int i = 0; i < genres.Count(); i++)
                    {
                        if (GetTagByName(genres[i]) != null)
                        {
                            listing.Product.AddTag(GetTagByName(genres[i]));
                        }
                        else
                        {
                            Tag tag = new Tag(genres[i]);
                            listing.Product.AddTag(tag);
                        }
                    }
                }

                productDetail.Genres = genresList.ToArray();
            }

            if (!appData["recommendations"].IsNullOrEmpty())
            {
                productDetail.TotalRecommendations = (appData["recommendations"]["total"].IsNullOrEmpty()) ? 0 : (int)appData["recommendations"]["total"];
            }

            if (!appData["achievements"].IsNullOrEmpty())
            {
                productDetail.NumAchievements = (appData["achievements"]["total"].IsNullOrEmpty()) ? 0 : (int)appData["achievements"]["total"];
            }

            if (!appData["release_date"].IsNullOrEmpty())
            {
                productDetail.ReleaseDate = (string)appData["release_date"]["date"] ?? "";
            }

            // run a sub-routine to build a listing/product for the base game of this demo/DLC
            if (baseAppID != 0)
            {
                Listing baseGameListing = GetListingByAppID(baseAppID, "Steam");

                if (baseGameListing == null)
                {
                    baseGameListing = new Listing(productDetail.BaseProductName);
                    baseGameListing.AddPlatform(GetPlatforms().Where(p => object.Equals(p.PlatformName, "Steam")).SingleOrDefault());
                    baseGameListing.AddProduct(new Product(baseAppID));

                    AddListing(baseGameListing);

                    BuildListingWithAppID(baseGameListing, baseAppID);

                    if (productDetail.ProductType.CompareTo("dlc") == 0)
                    {
                        baseGameListing.Product.ProductDetail.AddDLC(productDetail.Product);
                    }
                    else
                    {
                        productDetail.BaseProduct = baseGameListing.Product;
                    }

                    UpdateListing(baseGameListing);
                }
                else
                {
                    if (productDetail.ProductType.CompareTo("dlc") == 0)
                    {
                        baseGameListing.Product.ProductDetail.AddDLC(productDetail.Product);
                    }
                    else
                    {
                        productDetail.BaseProduct = baseGameListing.Product;
                    }
                }
            }

            // run a series of sub-routines to build listings/products for each DLC of this game (if applicable)
            if (productDetail.DLCAppIDs != null && productDetail.DLCAppIDs.Count() > 0)
            {
                for (int i = 0; i < productDetail.DLCAppIDs.Count(); i++)
                {
                    Listing DLCListing = GetListingByAppID(productDetail.DLCAppIDs[i], "Steam");

                    if (DLCListing == null)
                    {
                        DLCListing = new Listing();
                        DLCListing.AddPlatform(GetPlatforms().Where(p => object.Equals(p.PlatformName, "Steam")).SingleOrDefault());
                        DLCListing.AddProduct(new Product(productDetail.DLCAppIDs[i]));

                        AddListing(DLCListing);

                        BuildListingWithAppID(DLCListing, productDetail.DLCAppIDs[i]);

                        productDetail.AddDLC(DLCListing.Product);

                        UpdateListing(DLCListing);
                    }
                    else
                    {
                        productDetail.AddDLC(DLCListing.Product);
                    }
                }
            }

            if (!appData["movies"].IsNullOrEmpty())
            {
                JArray movies = (JArray)appData["movies"];

                for (int i = 0; i < movies.Count; i++)
                {
                    AppMovie temp = new AppMovie();

                    temp.Highlight = (!movies[i]["highlight"].IsNullOrEmpty()) ? false : (bool)movies[i]["highlight"];
                    temp.LargeMovieURL = (string)movies[i]["webm"]["max"] ?? "";
                    temp.Name = (string)movies[i]["name"] ?? "";
                    temp.SmallMovieURL = (string)movies[i]["webm"]["480"] ?? "";
                    temp.ThumbnailURL = (string)movies[i]["thumbnail"] ?? "";

                    productDetail.AddAppMovie(temp);
                }
            }

            if (!appData["screenshots"].IsNullOrEmpty())
            {
                JArray screenshots = (JArray)appData["screenshots"];

                for (int i = 0; i < screenshots.Count; i++)
                {
                    AppScreenshot temp = new AppScreenshot();

                    temp.FullSizeURL = (string)screenshots[i]["path_full"] ?? "";
                    temp.ThumbnailURL = (string)screenshots[i]["path_thumbnail"] ?? "";

                    productDetail.AddAppScreenshot(temp);
                }
            }

            if (!appData["categories"].IsNullOrEmpty())
            {
                JArray jCategories = (JArray)appData["categories"];
                List<string> categoriesList = new List<string>();

                for (int i = 0; i < jCategories.Count; i++)
                {
                    categoriesList.Add((string)jCategories[i]["description"]);
                }

                string[] categories = categoriesList.ToArray();

                if (categories != null)
                {
                    for (int i = 0; i < categories.Count(); i++)
                    {
                        if (GetProductCategoryByName(categories[i]) == null)
                        {
                            ProductCategory category = new ProductCategory(categories[i]);
                            listing.Product.AddProductCategory(category);
                        }
                        else
                        {
                            listing.Product.AddProductCategory(GetProductCategoryByName(categories[i]));
                        }
                    }
                }
            }

            listing.Product.AddProductDetail(productDetail);

            if (String.IsNullOrEmpty(listing.Product.ProductName))
            {
                listing.Product.ProductName = productDetail.ProductName;
            }
            if (String.IsNullOrEmpty(listing.ListingName))
            {
                listing.ListingName = productDetail.ProductName;
            }
        }
 public SelectedTagMapping(Tag tag, bool selected)
 {
     StoreTag = tag;
     IsSelected = selected;
 }