private void ParseEgenskaber(Beerstyle result, string egenskaberContent) { List <string> egenskaber = egenskaberContent.Substrings("<td>", "</td>"); if (egenskaber.Count == 5) { MinMaxValueElement minMaxOG = new MinMaxValueElement(egenskaber[0]); result.EgenskabOGMaximum = minMaxOG.MaxDoubleValue; result.EgenskabOGMinimum = minMaxOG.MinDoubleValue; MinMaxValueElement minMaxFG = new MinMaxValueElement(egenskaber[1]); result.EgenskabFGMaximum = minMaxFG.MaxDoubleValue; result.EgenskabFGMinimum = minMaxFG.MinDoubleValue; MinMaxValueElement minMaxEBC = new MinMaxValueElement(egenskaber[2]); result.EgenskabEBCMaximum = minMaxEBC.MaxIntValue; result.EgenskabEBCMinimum = minMaxEBC.MinIntValue; MinMaxValueElement minMaxIBU = new MinMaxValueElement(egenskaber[3]); result.EgenskabIBUMaximum = minMaxIBU.MaxIntValue; result.EgenskabIBUMinimum = minMaxIBU.MinIntValue; MinMaxValueElement minMaxAlkohol = new MinMaxValueElement(egenskaber[4]); result.EgenskabAlkoholMaximum = minMaxAlkohol.MaxDoubleValue; result.EgenskabAlkoholMinimum = minMaxAlkohol.MinDoubleValue; } }
private Beerstyle ParseStilart(string content) { //TODO: medtag StilartGruppe i constructor Beerstyle result = new Beerstyle(); result.BeerstyleKey = content.Substring("<td class=\"stylehdr\">", "</td>"); result.BeerstyleName = content.Substring("<td class=\"stylehdr\" align=\"right\" colspan=\"5\">", "</td>"); result.BeskrivelseGenereltIndtryk = ParseBeskrivelse(content, "generelt indtryk"); result.BeskrivelseUdseende = ParseBeskrivelse(content, "udseende"); result.BeskrivelseAroma = ParseBeskrivelse(content, "aroma"); result.BeskrivelseSmag = ParseBeskrivelse(content, "smag"); result.BeskrivelseKrop = ParseBeskrivelse(content, "krop"); result.BeskrivelseEksempler = ParseBeskrivelse(content, "eksempler"); List <string> egenskaberListe = content.Substrings("<tr bgcolor=\"white\" align=\"center\">", "</tr>"); if (egenskaberListe.Count == 2) { ParseEgenskaber(result, egenskaberListe[1]); } return(result); }
public async Task <IActionResult> OnGetAsync(int id, int beernumber = 0) { TempData["CustomError"] = null; BeerNumber = beernumber; if (!CheckAndReportLogin()) { return(Page()); } var tasting = _context.Tasting.FirstOrDefault(x => x.TastingId == id); if (tasting == null) { TempData["CustomError"] = "Invalid tasting, go home"; return(Page()); } if (!tasting.IsActive) { TempData["CustomError"] = "Tasting is not active, no votes allowed"; return(Page()); } if (tasting.TastingDate != null && DateTime.Now.Date < tasting.TastingDate.Date) { TempData["CustomError"] = "Tasting is not yet active"; return(Page()); } CurrentTasting = tasting; var beers = await _context.TastingBeer.Where(x => x.TastingId == id).OrderBy(x => x.SortOrder).ToListAsync(); var actualTastingBeer = beers.ElementAtOrDefault(beernumber); if (actualTastingBeer == null) { TempData["CustomError"] = $"Something went wrong, no beer at index {beernumber}"; return(Page()); } CurrentTastingBeer = actualTastingBeer; CurrentBeer = await _context.Beer.FirstOrDefaultAsync(x => x.BeerId == actualTastingBeer.BeerId); CurrentBeer.ABV = System.Math.Round(CurrentBeer.ABV, 2); if (actualTastingBeer == null) { TempData["CustomError"] = $"Something went wrong, unable to find beer with id {actualTastingBeer.BeerId}"; return(Page()); } CurrentBrewery = await _context.Brewery.FirstOrDefaultAsync(x => x.BreweryId == CurrentBeer.BreweryId); CurrentStyle = await _context.Beerstyle.FirstOrDefaultAsync(x => x.BeerstyleId == CurrentBeer.BeerStyleId); if (CurrentTasting.IsBlind) { CurrentBrewery.Country = "(N/A)"; CurrentBrewery.Name = "Hidden"; CurrentBrewery.Website = "_null"; CurrentBeer.Name = "Hidden"; CurrentBeer.ABV = 0.0; CurrentBeer.Beerstyle.Name = "Hidden"; CurrentBeer.RateBeerLink = "_null"; } CanGoBack = beernumber > 0; CanGoForward = beers.Count > beernumber + 1; var vote = _context.Vote.FirstOrDefault(x => x.BeerId == CurrentBeer.BeerId && x.TasterId == CurrentTaster.TasterId && x.TastingId == CurrentTasting.TastingId); if (vote == null) { CurrentVote = new Vote() { VoteId = -1, BeerId = CurrentBeer.BeerId, TasterId = CurrentTaster.TasterId, TastingId = id, Appearance = 0, Overall = 0, Taste = 0, Note = string.Empty }; } else { CurrentVote = vote; } return(Page()); }