Commit e8d6e0f3 authored by IJSlater's avatar IJSlater
Browse files

added dynamic site and linq

parent 8681b369
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
namespace CowboyCafe.Data namespace CowboyCafe.Data
{ {
public static class Menu public static class Menu
{ {
private static List<IOrderItem> entrees; public static List<IOrderItem> entrees;
private static List<IOrderItem> sides; public static List<IOrderItem> sides;
private static List<IOrderItem> drinks; public static List<IOrderItem> drinks;
public static List<IOrderItem> FilterEntrees(string check, string name, string mincal,string maxcal,string minprice, string maxprice) public static List<IOrderItem> FilterEntrees(string check, string name, string mincal,string maxcal,string minprice, string maxprice)
{ {
......
...@@ -26,75 +26,104 @@ ...@@ -26,75 +26,104 @@
<span>Max Price </span><input type="number" name="MaxPrice" value="@Model.MaxPrice" /><br /> <span>Max Price </span><input type="number" name="MaxPrice" value="@Model.MaxPrice" /><br />
</form> </form>
<p><a href="/handlerexample" class="btn btn-default">Click to Get</a></p> <p><a href="/handlerexample" class="btn btn-default">Click to Get</a></p>
<div class="menu" >
<div class="entrees" >
<h2>Entrees</h2>
<div class="entrees"> @foreach (IOrderItem entree in Model.entrees)
<h2>Entrees</h2> {
@foreach (IOrderItem entree in Model.entrees)
{
@entree.ToString() @entree.ToString()
<span>Price: </span>@entree.Price <span>Price: </span>@entree.Price
<span>Calories: </span>@entree.Calories<br><br /> <span>Calories: </span>@entree.Calories<br/><br/>
} }
</div> </div>
<div class="sides"> <div class="sides" >
<h2>Sides</h2> <h2>Sides</h2>
@foreach (Side sides in Model.sides) @foreach (Side sides in Model.sides)
{ {
{@sides.ToString().Substring(6)}<br /> {@sides.ToString().Substring(6)}<br />
<span>Price | Small: $</span>@sides.Price <span>Price | Small: $</span>@sides.Price
{ sides.Size = Size.Medium; } { sides.Size = Size.Medium; }
<span> Medium: $</span>@sides.Price <span> Medium: $</span>@sides.Price
{ sides.Size = Size.Large; } { sides.Size = Size.Large; }
<span> Large: $</span>@sides.Price<br /> <span> Large: $</span>@sides.Price<br />
{ sides.Size = Size.Small; } { sides.Size = Size.Small; }
<span>Calories | Small: </span>@sides.Calories <span>Calories | Small: </span>@sides.Calories
{ sides.Size = Size.Medium; } { sides.Size = Size.Medium; }
<span> Medium: </span>@sides.Calories <span> Medium: </span>@sides.Calories
{ sides.Size = Size.Large; } { sides.Size = Size.Large; }
<span> Large: </span>@sides.Calories<br /><br /> <span> Large: </span>@sides.Calories<br /><br />
} }
</div> </div>
<div class="drinks"> <div class="drinks">
<h2>Drinks</h2> <h2>Drinks</h2>
@foreach (Drink drinks in Model.drinks) @foreach (Drink drinks in Model.drinks)
{ {
{@drinks.ToString().Substring(6)}<br /> {@drinks.ToString().Substring(6)}<br />
<span>Price | Small: $</span>@drinks.Price <span>Price | Small: $</span>@drinks.Price
{ drinks.Size = Size.Medium; } { drinks.Size = Size.Medium; }
<span> Medium: $</span>@drinks.Price <span> Medium: $</span>@drinks.Price
{ drinks.Size = Size.Large; } { drinks.Size = Size.Large; }
<span> Large: $</span>@drinks.Price<br /> <span> Large: $</span>@drinks.Price<br />
{ drinks.Size = Size.Small; } { drinks.Size = Size.Small; }
<span>Calories | Small: </span>@drinks.Calories <span>Calories | Small: </span>@drinks.Calories
{ drinks.Size = Size.Medium; } { drinks.Size = Size.Medium; }
<span> Medium: </span>@drinks.Calories <span> Medium: </span>@drinks.Calories
{ drinks.Size = Size.Large; } { drinks.Size = Size.Large; }
<span> Large: </span>@drinks.Calories<br /><br /> <span> Large: </span>@drinks.Calories<br /><br />
} }
</div>
</div>
</div> </div>
</div>
\ No newline at end of file <style>
.entrees {
float: left;
width: 30%;
}
.sides {
float: left;
width: 30%;
}
.drinks {
float: left;
width: 30%;
}
@@media (max-width: 490px) {
.entrees {
float: none;
}
.sides {
float: none;
}
.drinks {
float: none;
}
}
</style>
\ No newline at end of file
...@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; ...@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using CowboyCafe.Data; using CowboyCafe.Data;
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.View;
namespace Website.Pages namespace Website.Pages
{ {
...@@ -17,9 +18,9 @@ namespace Website.Pages ...@@ -17,9 +18,9 @@ namespace Website.Pages
{ {
_logger = logger; _logger = logger;
} }
public List<IOrderItem> entrees =(List<IOrderItem>)Menu.Entrees(); public IEnumerable<IOrderItem> entrees =Menu.Entrees();
public List<IOrderItem> sides = (List<IOrderItem>)Menu.Sides(); public IEnumerable<IOrderItem> sides = Menu.Sides();
public List<IOrderItem> drinks = (List<IOrderItem>)Menu.Drinks(); public IEnumerable<IOrderItem> drinks = Menu.Drinks();
public string SearchTerms { get; set; } = "Search for Item"; public string SearchTerms { get; set; } = "Search for Item";
public string EntreeCheck { get; set; } public string EntreeCheck { get; set; }
public string DrinkCheck { get; set; } public string DrinkCheck { get; set; }
...@@ -40,9 +41,9 @@ namespace Website.Pages ...@@ -40,9 +41,9 @@ namespace Website.Pages
public void OnPost() public void OnPost()
{ {
entrees = (List<IOrderItem>)Menu.Entrees(); entrees = Menu.Entrees();
sides = (List<IOrderItem>)Menu.Sides(); sides = Menu.Sides();
drinks = (List<IOrderItem>)Menu.Drinks(); drinks = Menu.Drinks();
if (Request.Form["EntreeCheck"] == "on") if (Request.Form["EntreeCheck"] == "on")
EntreeCheck = "checked"; EntreeCheck = "checked";
...@@ -52,14 +53,14 @@ namespace Website.Pages ...@@ -52,14 +53,14 @@ namespace Website.Pages
} }
if (Request.Form["SideCheck"] == "on") if (Request.Form["SideCheck"] == "on")
EntreeCheck = "checked"; SideCheck = "checked";
else else
{ {
SideCheck = null; SideCheck = null;
} }
if (Request.Form["DrinkCheck"] == "on") if (Request.Form["DrinkCheck"] == "on")
EntreeCheck = "checked"; DrinkCheck = "checked";
else else
{ {
DrinkCheck = null; DrinkCheck = null;
...@@ -69,14 +70,20 @@ namespace Website.Pages ...@@ -69,14 +70,20 @@ namespace Website.Pages
MaxCal = Request.Form["MaxCalories"]; MaxCal = Request.Form["MaxCalories"];
MinPrice = Request.Form["MinPrice"]; MinPrice = Request.Form["MinPrice"];
MaxPrice = Request.Form["MaxPrice"]; MaxPrice = Request.Form["MaxPrice"];
string hold = Request.Form["SearchTerms"];
if(EntreeCheck!=null)
entrees = from item in Menu.Entrees()
entrees = Menu.FilterEntrees(Request.Form["EntreeCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]); where item.ToString().ToLower().Contains(hold.ToLower()) && item.Calories >= Convert.ToUInt32(Request.Form["MinCalories"]) && item.Calories <= Convert.ToUInt32(Request.Form["MaxCalories"]) && item.Price >= Convert.ToDouble(Request.Form["MinPrice"]) && item.Price <= Convert.ToDouble(Request.Form["MaxPrice"])
sides = Menu.FilterSides(Request.Form["SideCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]); select item;
drinks = Menu.FilterDrinks(Request.Form["DrinkCheck"], Request.Form["SearchTerms"], Request.Form["MinCalories"], Request.Form["MaxCalories"], Request.Form["MinPrice"], Request.Form["MaxPrice"]); if (DrinkCheck != null)
drinks = from item in Menu.Drinks()
where item.ToString().Contains(hold.ToLower()) && item.Calories >= Convert.ToUInt32(Request.Form["MinCalories"]) && item.Calories <= Convert.ToUInt32(Request.Form["MaxCalories"]) && item.Price >= Convert.ToDouble(Request.Form["MinPrice"]) && item.Price <= Convert.ToDouble(Request.Form["MaxPrice"])
select item;
if (SideCheck != null)
sides = from item in Menu.Sides()
where item.ToString().Contains(hold.ToLower()) && item.Calories >= Convert.ToUInt32(Request.Form["MinCalories"]) && item.Calories <= Convert.ToUInt32(Request.Form["MaxCalories"]) && item.Price >= Convert.ToDouble(Request.Form["MinPrice"]) && item.Price <= Convert.ToDouble(Request.Form["MaxPrice"])
select item;
} }
} }
} }
...@@ -35,6 +35,10 @@ html { ...@@ -35,6 +35,10 @@ html {
} }
} }
.border-top { .border-top {
border-top: 1px solid #e5e5e5; border-top: 1px solid #e5e5e5;
} }
...@@ -69,3 +73,6 @@ body { ...@@ -69,3 +73,6 @@ body {
white-space: nowrap; white-space: nowrap;
line-height: 60px; /* Vertically center the text there */ line-height: 60px; /* Vertically center the text there */
} }
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