public ExporterValidationResults Validate(ProductCatalogItem item) { var results = new ExporterValidationResults(); if (string.IsNullOrEmpty(item.id)) { results.fieldErrors["id"] = "ID field is required for cloud upload"; } if (string.IsNullOrEmpty(item.defaultDescription.Title)) { results.fieldErrors["defaultDescription.Title"] = "Title is required for cloud upload"; } if (item.googlePrice.value < 0) { results.fieldErrors["googlePrice"] = "Google price cannot be less than 0"; } if (item.googlePrice.value > kMaxGooglePrice) { results.fieldErrors["googlePrice"] = string.Format("Google price cannot be greater than {0}", kMaxGooglePrice); } return(results); }
public ExporterValidationResults Validate(ProductCatalogItem item) { var results = new ExporterValidationResults(); // Check for missing IDs if (string.IsNullOrEmpty(item.id)) { results.fieldErrors["id"] = "ID is required"; } // Check for missing title if (string.IsNullOrEmpty(item.defaultDescription.Title)) { results.fieldErrors["defaultDescription.Title"] = "Title is required"; } // Check for missing description if (string.IsNullOrEmpty(item.defaultDescription.Description)) { results.fieldErrors["defaultDescription.Description"] = "Description is required"; } // Check for screenshot if (string.IsNullOrEmpty(item.screenshotPath)) { results.fieldErrors["screenshotPath"] = "Screenshot is required"; } else { kFilesToCopy.Add(item.screenshotPath); } return(results); }
// Get Product Information public void productInformation(string productID) { foreach (var product in catalog.allProducts) { if (product.id == productID) { currentProduct = product; } } }
private static string ProductTypeString(ProductCatalogItem item) { switch (item.type) { case ProductType.Consumable: return("consumable"); case ProductType.NonConsumable: return("non-consumable"); case ProductType.Subscription: return("subscription"); } return(string.Empty); }
private static string PackTitlesAndDescriptions(ProductCatalogItem product) { var values = new List <string>(); values.Add(product.defaultDescription.googleLocale.ToString()); values.Add(SSVEscape(product.defaultDescription.Title)); values.Add(SSVEscape(product.defaultDescription.Description)); foreach (var desc in product.translatedDescriptions) { values.Add(desc.googleLocale.ToString()); values.Add(SSVEscape(desc.Title)); values.Add(SSVEscape(desc.Description)); } return(CSVEscape(string.Join(kSemicolon, values.ToArray()))); }
public ExporterValidationResults Validate(ProductCatalogItem item) { var results = new ExporterValidationResults(); // Check for missing IDs if (string.IsNullOrEmpty(item.id)) { results.errors.Add("ID is required"); } // A product ID must start with a lowercase letter or a number and must be composed // of only lowercase letters (a-z), numbers (0-9), underscores (_), and periods (.) string actualID = item.GetStoreID(GooglePlay.Name) ?? item.id; string field = (actualID == item.GetStoreID(GooglePlay.Name)) ? "storeID." + GooglePlay.Name : "id"; if (Char.IsNumber(actualID[0]) || (Char.IsLower(actualID[0]) && Char.IsLetter(actualID[0]))) { foreach (char c in actualID) { if (c != '_' && c != '.' && !Char.IsNumber(c) && !(Char.IsLetter(c) && Char.IsLower(c))) { results.fieldErrors[field] = "Product ID \"" + actualID + "\" must contain only lowercase letters, numbers, underscores, and periods"; } } } else { results.fieldErrors[field] = "Product ID \"" + actualID + "\" must start with a lowercase letter or a number"; } ValidateDescription(item.defaultDescription, ref results, "defaultDescription"); foreach (var desc in item.translatedDescriptions) { ValidateDescription(desc, ref results); } // Check for missing price information if (string.IsNullOrEmpty(item.pricingTemplateID) && item.googlePrice.value == 0) { results.fieldErrors["googlePrice"] = "Items must have either a price or a pricing template ID"; } return(results); }
private static string PackPrice(ProductCatalogItem product) { return(CSVEscape(Convert.ToInt32(product.googlePrice.value * kPriceMicroUnitMultiplier).ToString())); }