Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Add a Poem to the Database!!
Browse files Browse the repository at this point in the history
Big Changes!
Added a page where users can submit a poem to be added to the database.
Added a secret page! 🍔🍔🍔
Added a link to Github
  • Loading branch information
MetzinAround committed Oct 18, 2020
1 parent 0cb23a7 commit f2dd43c
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 2 deletions.
28 changes: 28 additions & 0 deletions Your New Favorite Poem/Pages/AddPoet.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@page
@model Your_New_Favorite_Poem.Pages.AddPoetModel
@{
ViewData["Title"] = "Add a Poet";
}
<head>
<title>Your New Favorite Poem</title>
<link href="~/css/site.css" rel="stylesheet" />
</head>
<body>
<form method="post" asp-page="AddPoet">
<section class="Author">
<label for="Author">What is the name of the poet?</label>
<input type="text" name="author" id="author">
</section>
<section class="Poem">
<label for="Poem">What is the url for the poem?</label>
<input type="text" name="poem" id="poem">
</section>
<section class="PoemName">
<label for="PoemName">What is the name of the poem?</label>
<input type="text" name="poemName" id="poemName">
</section>
<section class="submission">
<input type="submit" value="Submit Poem" asp-page-handler="Submit">
</section>
</form>
</body>
41 changes: 41 additions & 0 deletions Your New Favorite Poem/Pages/AddPoet.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Your_New_Favorite_Poem.Database;
using Your_New_Favorite_Poem.Models;

namespace Your_New_Favorite_Poem.Pages
{
public class AddPoetModel : PageModel
{
public async Task OnPostSubmit(string author, string poem, string poemName)
{
var isValidUri = Uri.TryCreate(poem, UriKind.Absolute, out var poemUri);
if (!isValidUri || poemUri is null)
{
//notify user of invalid URL for poem
}
else
{
await _poemDatabase.InsertPoems(new Poem(author, poemName, poemUri));
}
}

public AddPoetModel(ILogger<AddPoetModel> logger, PoemDatabase poemDatabase)
{
_logger = logger;
_poemDatabase = poemDatabase;

}
private readonly PoemDatabase _poemDatabase;
private readonly ILogger<AddPoetModel> _logger;
public void OnGet()
{

}
}
}
96 changes: 96 additions & 0 deletions Your New Favorite Poem/Pages/BurgerSecrets.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
@page
@model Your_New_Favorite_Poem.Pages.BurgerSecretsModel
@{
ViewData["Title"] = "Burger Secrets!";
}

<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Rubik" rel="stylesheet">
<title>BURGER SECRETS</title>
</head>
<body>
<section id="overlay">
<img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/unit-6/htmlcss1-img_burger-logo.svg" alt="Davie's Burgers Logo" id="logo">
<hr>
<form method="post" asp-page="BurgerSecrets">
<h1>Create a burger!</h1>
<section class="protein">
<label for="patty">What type of protein would you like?</label>
<input type="text" name="patty" id="patty">
</section>
<hr>

<section class="patties">
<label for="amount">How many patties would you like?</label>
<input type="number" name="amount" id="amount">
</section>
<hr>

<section class="cooked">
<label for="doneness">How do you want your patty cooked</label>
<br>
<span>Rare</span>
<input type="range" name="doneness" id="doneness" value="3" min="1" max="5">
<span>Well-Done</span>
</section>
<hr>

<section class="toppings">
<span>What toppings would you like?</span>
<br>
<input type="checkbox" name="topping" id="lettuce" value="lettuce">
<label for="lettuce">Lettuce</label>
<input type="checkbox" name="topping" id="tomato" value="tomato">
<label for="tomato">Tomato</label>
<input type="checkbox" name="topping" id="onion" value="onion">
<label for="onion">Onion</label>
</section>
<hr>

<section class="cheesy">
<span>Would you like to add cheese?</span>
<br>
<input type="radio" name="cheese" id="yes" value="yes">
<label for="yes">Yes</label>
<input type="radio" name="cheese" id="no" value="yes">
<label for="no">No</label>
</section>
<hr>

<section class="bun-type">
<label for="bun">What type of bun would you like?</label>
<select name="bun" id="bun">
<option value="sesame">Sesame</option>
<option value="potatoe">Potato</option>
<option value="pretzel">Pretzel</option>
</select>
</section>
<hr>

<section class="sauce-selection">
<label for="sauce">What type of sauce would you like?</label>
<input list="sauces" id="sauce" name="sauce">
<datalist id="sauces">
<option value="ketchup"></option>
<option value="mayo"></option>
<option value="mustard"></option>
</datalist>
</section>
<hr>
<section class="extra-info">
<label for="extra">Anything else you want to add?</label>
<br>
<textarea id="extra" name="extra" rows="3" cols="40"></textarea>
</section>
<hr>

<section class="submission">
<input type="submit" value="Submit" asp-page ="./Submission">
</section>
</form>
</section>
</body>
</html>
17 changes: 17 additions & 0 deletions Your New Favorite Poem/Pages/BurgerSecrets.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Your_New_Favorite_Poem.Pages
{
public class BurgerSecretsModel : PageModel
{

public void OnGet()
{
}
}
}
5 changes: 3 additions & 2 deletions Your New Favorite Poem/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
</head>
<body>
<section class="text-center" id="Banner">
<h1 class="display-2">Welcome to your new Favorite Poem</h1>
<h1 class="display-2">Welcome to Your New Favorite Poem</h1>


<p>
This website is a place to discover new poets, the type of poets you wouldn't necessarily find in your English class.
They're worthy of a look and especially worthy of supporting.
</p>
<p>You can find the source code <a href="https://github.com/MetzinAround/Your-New-Favorite-Poem" target="_blank">here!</a></p>

</section>
</section>


<div class="buttonmove">
Expand Down
3 changes: 3 additions & 0 deletions Your New Favorite Poem/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Poets">Poets</a> <!--made a button, but it goes to an error-->
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/AddPoet">Add Poet</a>
</li>
</ul>
</div>
</div>
Expand Down
22 changes: 22 additions & 0 deletions Your New Favorite Poem/Pages/Submission.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@page
@model Your_New_Favorite_Poem.Pages.SubmissionModel
@{
ViewData["Title"] = "Submission";
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Rubik" rel="stylesheet">
<title>Forms Review</title>
</head>
<body>
<section id="overlay">
<img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/unit-6/htmlcss1-img_burger-logo.svg" alt="Davie's Burgers Logo" id="logo">
<hr>
<h1>Thanks for your submission!</h1>
<img id="burger" src="https://s3.amazonaws.com/codecademy-content/courses/learn-html-forms/burger.svg" alt="finished burger">
</section>
</body>
</html>
16 changes: 16 additions & 0 deletions Your New Favorite Poem/Pages/Submission.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Your_New_Favorite_Poem.Pages
{
public class SubmissionModel : PageModel
{
public void OnGet()
{
}
}
}

0 comments on commit f2dd43c

Please sign in to comment.