internal static void ByAnimal(Models.Condition Condition, ref List <DataLayer.DataManager.dbCondition> SelectConditions) { DataLayer.Animal Animal = DataLayer.Animal.All; Enum.TryParse <DataLayer.Animal>(Condition.Animal, out Animal); SelectConditions.Add((DataLayer.Post CurrentPost) => { if (Animal == DataLayer.Animal.All) { return(true); } else if (CurrentPost.Type == Animal) { return(true); } else { return(false); } }); }
public IHttpActionResult UpdateDb() { String Answer = "Nothing"; try { List <String> Urls = new List <string>(); List <String> Animals = new List <string>() { "dogs", "cats", "birds", "rodents", "reptile", "fish", "insects", "horses", "Домашний-скот", "exotic" }; using (var Parser = new PageParser()) { List <String> Types = new List <string>() { "sale", "buy", "love", "free" }; List <DataLayer.Post> ParsedPosts = new List <DataLayer.Post>(); foreach (String AnimalPage in Animals) { foreach (String Type in Types) { using (var ZooParser = new Content.ZooParser()) { Parser.OnParsed = (String ParsedUrl) => { if (ParsedUrl != "") { DataLayer.DealType Dt = DataLayer.DealType.All; Enum.TryParse <DataLayer.DealType>(Type, out Dt); DataLayer.Animal An = DataLayer.Animal.All; Enum.TryParse <DataLayer.Animal>(AnimalPage, out An); ZooParser.OnParsed = (DataLayer.Post ParsedPost) => { ParsedPosts.Add(ParsedPost); }; if (AnimalPage != "Домашний-скот") { ZooParser.ParsePost(ParsedUrl, An, Dt); } else { ZooParser.ParsePost(ParsedUrl, DataLayer.Animal.Home, Dt); } } }; Parser.ParsePage("http://www.zoo-zoo.ru/" + AnimalPage + "/" + Type + "/"); } } } DataLayer.DataManager.AddList = ParsedPosts; Answer = "True"; } } catch (Exception ex) { Console.WriteLine(ex.Message); Answer = "False"; } return(Ok(Answer)); }