Commit 8681b369 authored by IJSlater's avatar IJSlater
Browse files

added filters for website

parent 0e7ad030
......@@ -10,6 +10,102 @@ namespace CowboyCafe.Data
private static List<IOrderItem> sides;
private static List<IOrderItem> drinks;
public static List<IOrderItem> FilterEntrees(string check, string name, string mincal,string maxcal,string minprice, string maxprice)
{
List<IOrderItem> ret = new List<IOrderItem>();
if (check == null)
{
foreach (IOrderItem item in Menu.entrees)
{
if (item is Entree entree)
{
ret.Add(entree);
}
}
return ret;
}
foreach (IOrderItem item in Menu.entrees)
{
if (item is Entree entree)
{
if (entree.ToString().ToLower().Contains(name.ToLower()) || name == "" || name == "Search for Item")
if (entree.Calories >= Convert.ToDouble(mincal) && entree.Calories <= Convert.ToDouble(maxcal))
if (entree.Price >= Convert.ToDouble(minprice) && entree.Price <= Convert.ToDouble(maxprice))
ret.Add(entree);
}
}
return ret;
}
public static List<IOrderItem> FilterSides(string check, string name, string mincal, string maxcal, string minprice, string maxprice)
{
List<IOrderItem> ret = new List<IOrderItem>();
if (check == null)
{
foreach (IOrderItem item in Menu.sides)
{
if (item is Side side)
{
ret.Add(side);
}
}
return ret;
}
foreach (IOrderItem item in Menu.sides)
{
if (item is Side side)
{
if (side.ToString().ToLower().Contains(name.ToLower()) || name == "" || name == "Search for Item")
if (side.Calories >= Convert.ToDouble(mincal) && side.Calories <= Convert.ToDouble(maxcal))
if (side.Price >= Convert.ToDouble(minprice) && side.Price <= Convert.ToDouble(maxprice))
ret.Add(side);
}
}
return ret;
}
public static List<IOrderItem> FilterDrinks(string check, string name, string mincal, string maxcal, string minprice, string maxprice)
{
List<IOrderItem> ret = new List<IOrderItem>();
if (check == null)
{
foreach (IOrderItem item in Menu.drinks)
{
if (item is Drink drink)
{
ret.Add(drink);
}
}
return ret;
}
foreach (IOrderItem item in Menu.drinks)
{
if (item is Drink drink)
{
if (drink.ToString().ToLower().Contains(name.ToLower()) || name == "" || name == "Search for Item")
if (drink.Calories >= Convert.ToDouble(mincal) && drink.Calories <= Convert.ToDouble(maxcal))
if (drink.Price >= Convert.ToDouble(minprice) && drink.Price <= Convert.ToDouble(maxprice))
ret.Add(drink);
}
}
return ret;
}
static Menu()
{
......
......@@ -5,93 +5,96 @@
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>We at Cowboy Cafe are proud to bring you authentic trail meals from the American West. Shake off the dust on your boots and sake your thirst with one of our old-fashioned hand-jerked sodas. Dip your Pan de Campo into a bowl of beans. Or conquer the the mighty Texas Triple Burger! You’ve had a hard ride - so take it easy with us.</p>
<form>
<input type="text" id="SearchTerms" @*value="@Model.SearchTerms"*@ />
<input type="submit" value="Submit" /><br>
<span>Entree </span><input type="checkbox" id="EntreeCheck" value="@Model.EntreeCheck" />
<span>Drink </span><input type="checkbox" id="DrinkCheck" value="@Model.DrinkCheck" />
<span>Side </span><input type="checkbox" id="SideCheck" value="@Model.SideCheck" /><br>
<form method="post">
<input type="text" name="SearchTerms" value="@Model.SearchTerms" />
<input type="submit" value="Submit" /><br>
<span>Minimum Calories </span><input class="number" type="number" id="MinCalories" value="@Model.MinCal" />
<span>Max Calories </span><input type="number" id="MaxCalories" value="@Model.MaxCal" /><br />
<span>Entree </span><input type="checkbox" name="EntreeCheck" checked="@Model.EntreeCheck" />
<span>Drink </span><input type="checkbox" name="DrinkCheck" checked="@Model.DrinkCheck" />
<span>Side </span><input type="checkbox" name="SideCheck" checked="@Model.SideCheck" /><br>
<span>Minimum Price </span><input type="number" id="MinPrice" value="@Model.MinPrice" />
<span>Max Price </span><input type="number" id="MaxPrice" value="@Model.MaxPrice" /><br />
<span>Minimum Calories </span><input class="number" type="number" name="MinCalories" value="@Model.MinCal" />
<span>Max Calories </span><input type="number" name="MaxCalories" value="@Model.MaxCal" /><br />
<span>Minimum Price </span><input type="number" name="MinPrice" value="@Model.MinPrice" />
<span>Max Price </span><input type="number" name="MaxPrice" value="@Model.MaxPrice" /><br />
</form>
<div class="entrees">
<h2>Entrees</h2>
<p><a href="/handlerexample" class="btn btn-default">Click to Get</a></p>
<div class="entrees">
<h2>Entrees</h2>
@foreach (IOrderItem entree in Model.entrees)
{
@foreach (Entree entree in Menu.Entrees())
{
@entree.ToString()
<span>Price: </span>@entree.Price
<span>Calories: </span>@entree.Calories<br><br />
@entree.ToString()
<span>Price: </span>@entree.Price
<span>Calories: </span>@entree.Calories<br><br />
}
</div>
<div class="sides">
<h2>Sides</h2>
}
</div>
<div class="sides">
<h2>Sides</h2>
@foreach (Side sides in Menu.Sides())
{
@foreach (Side sides in Model.sides)
{
{@sides.ToString().Substring(6)}<br />
{@sides.ToString().Substring(6)}<br />
<span>Price | Small: $</span>@sides.Price
{ sides.Size = Size.Medium; }
<span> Medium: $</span>@sides.Price
<span>Price | Small: $</span>@sides.Price
{ sides.Size = Size.Medium; }
<span> Medium: $</span>@sides.Price
{ sides.Size = Size.Large; }
<span> Large: $</span>@sides.Price<br />
{ sides.Size = Size.Large; }
<span> Large: $</span>@sides.Price<br />
{ sides.Size = Size.Small; }
<span>Calories | Small: </span>@sides.Calories
{ sides.Size = Size.Medium; }
<span> Medium: </span>@sides.Calories
{ sides.Size = Size.Large; }
<span> Large: </span>@sides.Calories<br /><br />
{ sides.Size = Size.Small; }
<span>Calories | Small: </span>@sides.Calories
{ sides.Size = Size.Medium; }
<span> Medium: </span>@sides.Calories
{ sides.Size = Size.Large; }
<span> Large: </span>@sides.Calories<br /><br />
}
</div>
<div class="drinks">
<h2>Drinks</h2>
@foreach (Drink drinks in Menu.Drinks())
{
}
</div>
<div class="drinks">
<h2>Drinks</h2>
{@drinks.ToString().Substring(6)}<br />
<span>Price | Small: $</span>@drinks.Price
@foreach (Drink drinks in Model.drinks)
{
{@drinks.ToString().Substring(6)}<br />
<span>Price | Small: $</span>@drinks.Price
{ drinks.Size = Size.Medium; }
<span> Medium: $</span>@drinks.Price
{ drinks.Size = Size.Large; }
<span> Large: $</span>@drinks.Price<br />
{ drinks.Size = Size.Medium; }
<span> Medium: $</span>@drinks.Price
{ drinks.Size = Size.Large; }
<span> Large: $</span>@drinks.Price<br />
{ drinks.Size = Size.Small; }
<span>Calories | Small: </span>@drinks.Calories
{ drinks.Size = Size.Medium; }
<span> Medium: </span>@drinks.Calories
{ drinks.Size = Size.Large; }
<span> Large: </span>@drinks.Calories<br /><br />
{ drinks.Size = Size.Small; }
<span>Calories | Small: </span>@drinks.Calories
{ drinks.Size = Size.Medium; }
<span> Medium: </span>@drinks.Calories
{ drinks.Size = Size.Large; }
<span> Large: </span>@drinks.Calories<br /><br />
}
</div>
}
</div>
</div>
\ No newline at end of file
......@@ -17,30 +17,65 @@ namespace Website.Pages
{
_logger = logger;
}
public List<IOrderItem> entrees =(List<IOrderItem>)Menu.Entrees();
public List<IOrderItem> sides = (List<IOrderItem>)Menu.Sides();
public List<IOrderItem> drinks = (List<IOrderItem>)Menu.Drinks();
public string SearchTerms { get; set; } = "Search for Item";
public bool EntreeCheck { get; set; }
public bool DrinkCheck { get; set; }
public bool SideCheck { get; set; }
public uint MinCal { get; set; }
public uint MaxCal { get; set; }
public double MinPrice { get; set; }
public double MaxPrice { get; set; }
public string EntreeCheck { get; set; }
public string DrinkCheck { get; set; }
public string SideCheck { get; set; }
public string MinCal { get; set; } = "0";
public string MaxCal { get; set; } = "900";
public string MinPrice { get; set; } = "0.00";
public string MaxPrice { get; set; } = "50.00";
public List<IOrderItem> Entrees;
public List<IOrderItem> Sides;
public List<IOrderItem> Drinks;
public void OnGet()
{
SearchTerms = Request.Form.ToString();
//Entrees
}
public void OnPost()
{
entrees = (List<IOrderItem>)Menu.Entrees();
sides = (List<IOrderItem>)Menu.Sides();
drinks = (List<IOrderItem>)Menu.Drinks();
if (Request.Form["EntreeCheck"] == "on")
EntreeCheck = "checked";
else
{
EntreeCheck = null;
}
if (Request.Form["SideCheck"] == "on")
EntreeCheck = "checked";
else
{
SideCheck = null;
}
if (Request.Form["DrinkCheck"] == "on")
EntreeCheck = "checked";
else
{
DrinkCheck = null;
}
SearchTerms = Request.Form["SearchTerms"];
MinCal = Request.Form["MinCalories"];
MaxCal = Request.Form["MaxCalories"];
MinPrice = Request.Form["MinPrice"];
MaxPrice = Request.Form["MaxPrice"];
entrees = Menu.FilterEntrees(Request.Form["EntreeCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]);
sides = Menu.FilterSides(Request.Form["SideCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]);
drinks = Menu.FilterDrinks(Request.Form["DrinkCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment