protected override List <ISizeMapNode> ParseHtml(string response) { //https://www.sivasdescalzo.com/en/sb-zoom-blazer-mid-edge-ci3833-101 var shoesSizeMap = new List <ISizeMapNode>(); var regex = Regex.Match(response, "options\":(.*]}])").Groups[1].Value; var price = Regex.Match(response, "\"price_info\":{\"final_price\":(.*?),").Groups[1].Value; if (response.Contains("<span>Sold out</span>")) { return(shoesSizeMap); } var sizesContainer = JArray.Parse(regex); foreach (var sizeNode in sizesContainer) { var shoeContext = new ShoeContext() { ExternalSize = sizeNode["label"].ToObject <string>().Trim(), ExternalPrice = Convert.ToDouble(price), Quantity = sizeNode["products"].ToObject <IEnumerable <object> >().Count() != 0 ? 999 : 0 }; shoesSizeMap.Add(shoeContext); } return(shoesSizeMap); }
protected override List <ISizeMapNode> ParseHtml(string response) { var shoesSizeMap = new List <ISizeMapNode>(); var urlRegex = Regex .Match(response, URL_REGEX_PATTERN).Groups[0].Value; var url = JObject.Parse(urlRegex)["eliteURL"].ToString(); var variantsRegex = Regex .Match(response, VARIANTS_REGEX_PATTERN).Groups[0].Value; var sizesContainer = JObject.Parse(variantsRegex); foreach (var sizeVariantsObject in sizesContainer.Children().Children()) { if (url.Contains(sizeVariantsObject["pf_url"].ToString())) { var ShoeContext = new ShoeContext() { ExternalSize = sizeVariantsObject["option2"].ToObject <string>().Trim(), ExternalPrice = double.Parse(sizeVariantsObject["price"].ToString().Replace("£", ""), CultureInfo.InvariantCulture), Quantity = sizeVariantsObject["stock_status"].ToString() == IN_STOCK_TEXT ? 999 : 0 }; shoesSizeMap.Add(ShoeContext); } } return(shoesSizeMap); }
protected override List <ISizeMapNode> ParseHtml(string response) { //https://stockx.com/nike-air-huarache-drift-black-sail var shoesSizeMap = new List <ISizeMapNode>(); var doc = new HtmlDocument(); doc.LoadHtml(response); var sizesContainer = doc.DocumentNode.SelectNodes("//div[@id='market-summary']//li[contains(@class,'select-option') and not(contains(@class, 'all'))]"); foreach (var sizeNode in sizesContainer) { var priceNodeText = sizeNode.SelectSingleNode(".//div[@class='subtitle']"); var isSizeBid = priceNodeText.InnerText.Trim().ToLower() == "bid"; var shoeContext = new ShoeContext() { ExternalSize = sizeNode.SelectSingleNode(".//div[@class='title']") .InnerText .Replace("us ", "") .Trim(), ExternalPrice = isSizeBid ? 0 : Convert.ToDouble(priceNodeText .InnerText .Replace("$", ""), CultureInfo.InvariantCulture), Quantity = isSizeBid ? 0 : 999 }; shoesSizeMap.Add(shoeContext); } return(shoesSizeMap); }
public IEnumerable <Shoe> GetAll() { Func <Shoe, bool> IsSomethingAThing = x => true; // get all shoes fro mthe database var db = new ShoeContext(); return(db.Shoes.Where(IsSomethingAThing)); }
public ICollection <ShoeSize> GetShoeSizes() { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeSizes.ToList()); } } catch { return(null); } }
public ShoeComponent GetShoeComponent(int _shoeComponent) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeComponents.Find(_shoeComponent)); } } catch { return(null); } }
public CuttingType GetCuttingType(int _cuttingTypeId) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.CuttingTypes.Find(_cuttingTypeId)); } } catch { return(null); } }
public ShoeSize GetShoeSize(int _shoeSizeId) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeSizes.Find(_shoeSizeId)); } } catch { return(null); } }
public ShoeModel AddNewShoeModel(ShoeModel _shoeModel) { try { using (ShoeContext = new ShoeContext(database)) { _shoeModel = ShoeContext.ShoeModels.Add(_shoeModel); ShoeContext.SaveChanges(); return(_shoeModel); } } catch { return(null); } }
public ShoeComponent GetShoeComponent(string _componentRef) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeComponents .Where(i => i.Reference == _componentRef) .First()); } } catch { return(null); } }
public ShoeComponent AddNewShoeComponent(ShoeComponent _shoeComponent) { try { using (ShoeContext = new ShoeContext(database)) { _shoeComponent = ShoeContext.ShoeComponents.Add(_shoeComponent); ShoeContext.SaveChanges(); return(_shoeComponent); } } catch { return(null); } }
public bool ClearAllModelComponents() { try { using (ShoeContext = new ShoeContext(database)) { var modelComponent = ShoeContext.ModelComponents.ToList(); ShoeContext.ModelComponents.RemoveRange(modelComponent); ShoeContext.SaveChanges(); return(true); } } catch { return(false); } }
public ShoeModel GetShoeModel(string _shoeModelstr, string _shoeModelNamestr) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeModels .Include("ModelComponents") .Where(i => i.Model_Number == _shoeModelstr && i.Model_Name == _shoeModelNamestr) .First()); } } catch { return(null); } }
public ShoeModel GetShoeModel(int _shoeModelId) { try { using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ShoeModels .Include("ModelComponents") .Where(i => i.Id == _shoeModelId) .First()); } } catch { return(null); } }
public ModelComponent GetModelComponent(int _shoeModelId, string _cuttingType) { try { var cuttingType = GetCuttingType(_cuttingType); using (ShoeContext = new ShoeContext(database)) { return(ShoeContext.ModelComponents .Where(i => i.ShoeModel_Id == _shoeModelId && i.CuttingType_Id == cuttingType.id) .First()); } } catch { return(null); } }
public void Component() { using (var context = new ShoeContext(Database)) { if (context.Database.Exists()) { Console.WriteLine("ShoeContext is existing"); return; } context.Database.Create(); Console.WriteLine("ShoeContext is created successfully"); List <ShoeSize> sizes = new List <ShoeSize>(); for (int i = 0; i <= 15; i++) { sizes.AddRange(new ShoeSize[] { new ShoeSize { SizeName = $"{i}" }, new ShoeSize { SizeName = $"{i}T" } }); } context.ShoeSizes.AddRange(sizes); context.SaveChanges(); context.CuttingTypes.AddRange(new CuttingType[] { new CuttingType { TypeName = "auto cut" }, new CuttingType { TypeName = "beam cut" } }); context.SaveChanges(); try { context.Database.ExecuteSqlCommand("DROP TABLE [__MigrationHistory]"); context.SaveChanges(); } catch { } } }
public ShoeComponent AddNewShoeComponent(string _shoeComponentRef) { try { using (ShoeContext = new ShoeContext(database)) { ShoeComponent shoeComponent = new ShoeComponent { Reference = _shoeComponentRef, }; var result = ShoeContext.ShoeComponents.Add(shoeComponent); ShoeContext.SaveChanges(); return(result); } } catch { return(null); } }
public ModelComponent AddNewModelComponent(int _shoeModelId, int _shoeComponentId, int _cuttingTypeId) { try { using (ShoeContext = new ShoeContext(database)) { var modelComponent = ShoeContext.ModelComponents.Add(new ModelComponent { ShoeModel_Id = _shoeModelId, ShoeComponent_Id = _shoeComponentId, CuttingType_Id = _cuttingTypeId, }); ShoeContext.SaveChanges(); return(modelComponent); } } catch { return(null); } }
protected override List <ISizeMapNode> ParseHtml(string response) { var shoesSizeMap = new List <ISizeMapNode>(); var sizesContainer = JArray.Parse(response); foreach (var sizeNode in sizesContainer) { var price = sizeNode["lowestPriceCents"]["amount"].ToObject <string>(); var shoeContext = new ShoeContext() { ExternalSize = sizeNode["size"].ToObject <string>().Trim(), ExternalPrice = double.Parse(price.Substring(0, price.Length - 2), CultureInfo.InvariantCulture), Quantity = 999 }; shoesSizeMap.Add(shoeContext); } return(shoesSizeMap); }
public CuttingType GetCuttingType(string _cuttingType) { try { using (ShoeContext = new ShoeContext(database)) { var cutTypes = ShoeContext.CuttingTypes .Where(i => i.TypeName.Contains(_cuttingType)); if (cutTypes.Count() > 0) { return(cutTypes.First()); } var result = ShoeContext.CuttingTypes.Add(new CuttingType { TypeName = _cuttingType }); ShoeContext.SaveChanges(); return(result); } } catch { return(null); } }
public ShoeTypeRepository(ShoeContext db) { this.db = db; }
public ColorController(ShoeContext context) { _context = context; }
public HomeController(ShoeContext ctx) { context = ctx; }
public ShoesController(ShoeContext context) { _context = context; }