Commit e8d6e0f3 authored by IJSlater's avatar IJSlater
Browse files

added dynamic site and linq

parent 8681b369
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CowboyCafe.Data
{
public static class Menu
{
private static List<IOrderItem> entrees;
private static List<IOrderItem> sides;
private static List<IOrderItem> drinks;
public static List<IOrderItem> entrees;
public static List<IOrderItem> sides;
public static List<IOrderItem> drinks;
public static List<IOrderItem> FilterEntrees(string check, string name, string mincal,string maxcal,string minprice, string maxprice)
{
......
......@@ -26,8 +26,8 @@
<span>Max Price </span><input type="number" name="MaxPrice" value="@Model.MaxPrice" /><br />
</form>
<p><a href="/handlerexample" class="btn btn-default">Click to Get</a></p>
<div class="entrees">
<div class="menu" >
<div class="entrees" >
<h2>Entrees</h2>
@foreach (IOrderItem entree in Model.entrees)
......@@ -36,11 +36,11 @@
@entree.ToString()
<span>Price: </span>@entree.Price
<span>Calories: </span>@entree.Calories<br><br />
<span>Calories: </span>@entree.Calories<br/><br/>
}
</div>
<div class="sides">
<div class="sides" >
<h2>Sides</h2>
@foreach (Side sides in Model.sides)
......@@ -98,3 +98,32 @@
</div>
</div>
</div>
<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;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using CowboyCafe.Data;
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.View;
namespace Website.Pages
{
......@@ -17,9 +18,9 @@ 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 IEnumerable<IOrderItem> entrees =Menu.Entrees();
public IEnumerable<IOrderItem> sides = Menu.Sides();
public IEnumerable<IOrderItem> drinks = Menu.Drinks();
public string SearchTerms { get; set; } = "Search for Item";
public string EntreeCheck { get; set; }
public string DrinkCheck { get; set; }
......@@ -40,9 +41,9 @@ namespace Website.Pages
public void OnPost()
{
entrees = (List<IOrderItem>)Menu.Entrees();
sides = (List<IOrderItem>)Menu.Sides();
drinks = (List<IOrderItem>)Menu.Drinks();
entrees = Menu.Entrees();
sides = Menu.Sides();
drinks = Menu.Drinks();
if (Request.Form["EntreeCheck"] == "on")
EntreeCheck = "checked";
......@@ -52,14 +53,14 @@ namespace Website.Pages
}
if (Request.Form["SideCheck"] == "on")
EntreeCheck = "checked";
SideCheck = "checked";
else
{
SideCheck = null;
}
if (Request.Form["DrinkCheck"] == "on")
EntreeCheck = "checked";
DrinkCheck = "checked";
else
{
DrinkCheck = null;
......@@ -69,14 +70,20 @@ namespace Website.Pages
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"]);
string hold = Request.Form["SearchTerms"];
if(EntreeCheck!=null)
entrees = from item in Menu.Entrees()
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"])
select item;
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 {
}
}
.border-top {
border-top: 1px solid #e5e5e5;
}
......@@ -69,3 +73,6 @@ body {
white-space: nowrap;
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