/// <summary> /// Construct the view model from the <see cref="DomainResult"/> /// </summary> public DomainResultModel(DomainResult domainResult) : base(domainResult.Product) { domainName = domainResult.DomainName; status = domainResult.Status; domainSearchId = domainResult.DomainSearchId; order = domainResult.Order; }
/// <summary> /// Convert data from DomainSearch plugin to AtomiaStore native <see cref="Atomia.Store.Core.DomainResult"/> /// </summary> /// <param name="productId">Article number of the domain registration product</param> /// <param name="productStatus">Domain name availability status</param> /// <param name="productName">Name of the domain registration product</param> /// <param name="transactionId">Id of the search that the result is from</param> /// <returns>Single domain result</returns> private DomainResult CreateDomainResult(string productId, string productStatus, string productName, int transactionId) { var apiProduct = this.tldProducts.FirstOrDefault(p => p.ArticleNumber == productId); if (apiProduct == null) { throw new InvalidOperationException(string.Format("No TLD product with articlenumber {0}", productId)); } string productvalue; if (!apiProduct.Properties.TryGetValue("productvalue", out productvalue)) { throw new InvalidOperationException(String.Format("product {0} is missing required 'productvalue' property", productId)); } var status = DomainResult.UNKNOWN; switch (productStatus.ToLower()) { case ("processing"): case ("loading"): status = DomainResult.LOADING; break; case ("taken"): case ("unavailable"): case ("special"): status = DomainResult.UNAVAILABLE; break; case ("available"): status = DomainResult.AVAILABLE; break; case ("warning"): default: status = DomainResult.UNKNOWN; break; } var product = productMapper.Map(apiProduct); var tld = productvalue.ToLower().TrimStart('.'); var domainResult = new DomainResult(product, tld, productName, status, transactionId); // This makes sure results get the same Order property independent of if they are from initial search or status check. // Since tldProducts come directly from API they are sorted in that order. domainResult.Order = tldProducts.IndexOf(apiProduct); return domainResult; }
private DomainResult SetAvailable(DomainResult result) { return new DomainResult(result.Product, result.TLD, result.DomainName, DomainResult.AVAILABLE, result.DomainSearchId); }
public DomainSearchData FindDomains(ICollection<string> searchTerms) { var results = new List<DomainResult>(); var searchTerm = searchTerms.First(); var premiumTlds = new Dictionary<string, string> { {"com", DomainResult.AVAILABLE}, {"org", DomainResult.AVAILABLE}, {"net", DomainResult.AVAILABLE}, }; var secondaryTlds = new Dictionary<string, string> { {"se", DomainResult.AVAILABLE}, {"eu", DomainResult.UNAVAILABLE}, {"info", DomainResult.UNKNOWN}, {"co.uk", DomainResult.AVAILABLE}, // Uncomment if you need to test many tlds. Also see FakeCategoryProductsProvider /*{"de", DomainResult.AVAILABLE}, {"fr", DomainResult.UNAVAILABLE}, {"dk", DomainResult.AVAILABLE}, {"fi", DomainResult.UNAVAILABLE}, {"es", DomainResult.AVAILABLE}, {"co", DomainResult.UNAVAILABLE}, {"it", DomainResult.AVAILABLE}, {"io", DomainResult.UNAVAILABLE}, {"cloud", DomainResult.AVAILABLE}, {"global", DomainResult.UNAVAILABLE}, {"be", DomainResult.AVAILABLE}, {"ca", DomainResult.UNAVAILABLE}, {"mx", DomainResult.AVAILABLE}, {"pro", DomainResult.UNAVAILABLE}, {"aero", DomainResult.AVAILABLE}, {"asia", DomainResult.UNAVAILABLE}, {"au", DomainResult.AVAILABLE}, {"cl", DomainResult.UNAVAILABLE}, {"coop", DomainResult.AVAILABLE}, {"my", DomainResult.UNAVAILABLE}, {"sg", DomainResult.AVAILABLE}, {"hk", DomainResult.UNAVAILABLE}, {"hu", DomainResult.AVAILABLE}, {"jobs", DomainResult.UNAVAILABLE}, {"lv", DomainResult.AVAILABLE}, {"no", DomainResult.UNAVAILABLE}, {"nyc", DomainResult.AVAILABLE}, {"pm", DomainResult.UNAVAILABLE}, {"re", DomainResult.AVAILABLE}, {"tf", DomainResult.UNAVAILABLE}, {"wf", DomainResult.AVAILABLE}, {"yt", DomainResult.UNAVAILABLE}, {"ro", DomainResult.AVAILABLE}, {"ru", DomainResult.UNAVAILABLE}, {"nu", DomainResult.AVAILABLE}, {"travel", DomainResult.UNAVAILABLE}*/ }; if (!string.IsNullOrEmpty(searchTerm)) { lastSearchTerm = searchTerm; var renewalPeriods = new List<RenewalPeriod> { new RenewalPeriod(1, RenewalPeriod.YEAR) }; var i = 0; foreach (var tld in premiumTlds) { var domainResult = new DomainResult( new Product { ArticleNumber = "DMN-" + tld.Key.ToUpper(), PricingVariants = renewalPeriods.Select(r => new PricingVariant { Price = 10m, RenewalPeriod = r }).ToList(), CustomAttributes = new List<CustomAttribute> { new CustomAttribute { Name = "Premium", Value = "true"} , new CustomAttribute { Name = "productvalue", Value = "." + tld.Key} , } }, tld.Key, searchTerm + "." + tld.Key, tld.Value, 1 ); domainResult.Order = i++; results.Add(domainResult); } foreach (var tld in secondaryTlds) { var domainResult = new DomainResult( new Product { ArticleNumber = "DMN-" + tld.Key.ToUpper(), PricingVariants = renewalPeriods.Select(r => new PricingVariant { Price = 10m, RenewalPeriod = r }).ToList(), CustomAttributes = new List<CustomAttribute> { new CustomAttribute { Name = "productvalue", Value = "." + tld.Key} , } }, tld.Key, searchTerm + "." + tld.Key, tld.Value, 1 ); domainResult.Order = i++; results.Add(domainResult); } } var data = new DomainSearchData { FinishSearch = false, DomainSearchId = 1, Results = results }; return data; }