-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Dani Renner <[email protected]> Co-authored-by: Woo Jin Kim <[email protected]>
- Loading branch information
1 parent
227e748
commit b46c721
Showing
7 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Packer.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace Packer.Controllers | ||
{ | ||
public class ItemsController : Controller | ||
{ | ||
[HttpGet("/items")] | ||
public ActionResult Index() | ||
{ | ||
List<Item> allItems = Item.GetAll(); | ||
return View(allItems); | ||
} | ||
[HttpGet("/items/new")] | ||
public ActionResult New() | ||
{ | ||
return View(); | ||
} | ||
[HttpPost("/items")] | ||
public ActionResult Create(string name, bool packed, bool purchased) | ||
{ | ||
Item userItem = new Item(name, packed, purchased); | ||
return RedirectToAction("Index"); | ||
} | ||
[HttpGet("/items/{id}")] | ||
public ActionResult Show(int id) | ||
{ | ||
Item findItem = Item.Find(id); | ||
return View(findItem); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,38 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Packer.Models | ||
{ | ||
public class Item | ||
{ | ||
public string Name { get; set; } | ||
public bool Packed { get; set; } | ||
public bool Purchased { get; set; } | ||
public int Id { get; } | ||
|
||
private static List<Item> _instances = new List<Item>{}; | ||
|
||
public Item(string name, bool packed, bool purchased) | ||
{ | ||
Name = name; | ||
Packed = packed; | ||
Purchased = purchased; | ||
_instances.Add(this); | ||
Id = _instances.Count; | ||
} | ||
|
||
public static List<Item> GetAll() | ||
{ | ||
return _instances; | ||
} | ||
public static void ClearAll() | ||
{ | ||
_instances.Clear(); | ||
} | ||
|
||
public static Item Find(int searchId) | ||
{ | ||
return _instances[searchId-1]; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<p> hello! </p> | ||
<a href='/items'>See your packing list.</a> | ||
<a href='/items/new'>Let's add to your packing list!</a> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@using Packer.Models; | ||
|
||
<ul> | ||
@foreach(Item item in Model) | ||
{ | ||
<li><a href='items/@item.Id'>@item.Name</a></li> | ||
} | ||
</ul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<form action="/items" method="post"> | ||
<label for="name">Add a new item</label> | ||
<input id="name" name="name" type="text"> | ||
<label for="packed"> | ||
Packed | ||
<input id="packed" name="packed" value="true" type="radio"> | ||
</label> | ||
<label for="notPacked"> | ||
Not Packed | ||
<input id="notPacked" name="packed" value="false" type="radio"> | ||
</label> | ||
<label for="purchased"> | ||
Purchased | ||
<input id="purchased" name="purchased" value="true" type="radio"> | ||
</label> | ||
<label for="notPurchased"> | ||
Not Purchased | ||
<input id="notPurchased" name="purchased" value="false" type="radio"> | ||
</label> | ||
|
||
<button type="submit">Submit</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>ITEM DETAILS</p> | ||
|
||
<p>@Model.Name</p> | ||
<p>Packed: @Model.Packed</p> | ||
<p>Purchased: @Model.Purchased</p> |