Skip to content

Patt MacMillan - Velir Programming Test #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions TakeHome/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ public static void RegisterBundles(BundleCollection bundles)
"~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js"));
"~/Scripts/bootstrap.min.js"));
bundles.Add(new ScriptBundle("~/bundles/custom").Include(
"~/Scripts/main.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.min.css",
"~/Content/site.css"));
}
}
Expand Down
123 changes: 107 additions & 16 deletions TakeHome/Content/Site.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,115 @@
body {
padding-top: 50px;
padding-bottom: 20px;
/* Overall font family for site. */
* {
font-family: 'Montserrat', serif !important;
}

/* Set padding to keep content from hitting the edges */
/* Slight adjustment to general padding to account for header. */
.body-content {
padding-left: 15px;
padding-right: 15px;
margin-top: 50px;
}

/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
/* Small underline flair for headers. */
h1, h2, h3, h4 {
margin-bottom: 15px;
}

/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
h1:after, h2:after, h3:after, h4:after {
content: "";
padding-top: 15px;
border-bottom: 3px solid #cce5ff;
margin-bottom: 15px;
display: block;
}

/* Styling for form field validation errors. Shows and hides based on current state. */
form .editor-validation {
display: none;
margin-top: 15px;
position: relative;
}

form .editor-validation:before {
content: '';
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 15px 10px;
border-color: transparent transparent #f2dede transparent;
position: absolute;
top: -15px;
left: 15px;
}

form .input-validation-error + .editor-validation.active {
display: block;
}

form .input-validation-error + input {
border-color: #a94442;
}

form .editor-field {
position: relative;
}

/* Styling for the general form error message. Hides and shows based on state. */
.form-error {
display: none;
}

.form-error.active {
display: block;
}

/* Adjustments to bootstrap's built in accordion. */
.collapsed-content {
margin-bottom: 15px;
}

.collapsed-content .collapse-button {
color: #004085;
border: 1px solid #004085;
background-color: #cce5ff;
position: relative;
display: block;
padding: 15px 30px;
text-decoration: none;
font-weight: bold;
}

.collapsed-content .collapse-button:after {
content: "+";
font-size: 30px;
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
}

.collapsed-content .card-body {
padding-top: 30px;
padding-bottom: 30px;
border: 1px solid #004085;
border-top: 0;
}

.collapsed-content .card-body a {
font-weight: bold;
color: #004085;
}

.collapsed-content .card-body > ul, .collapsed-content .card-body > p {
padding-right: 30px;
}

.collapsed-content .card-body > p {
padding-left: 30px;
}

.collapsed-content .card-body > ul > li {
padding-bottom: 15px;
}

.collapsed-content span {
font-weight: bold;
}
46 changes: 46 additions & 0 deletions TakeHome/Controllers/ErrorController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TakeHome.Models;

namespace TakeHome.Controllers
{
/// <summary>
/// Controller for Error pages and related functionality.
/// </summary>
public class ErrorController : Controller
{
/// <summary>
/// Represents the error page (500 and related codes) for the website.
/// </summary>
/// <param name="error"></param>
/// <returns>Returns the content for the Error page.</returns>
public ActionResult Error()
{
return View("Error");
}

/// <summary>
/// Represents the NotFound (404) page.
/// </summary>
/// <returns></returns>
public ActionResult NotFound()
{
// Set status code to 404 and skip IIS errors to display the intended URL and prevent
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
return View("NotFound");
}

/// <summary>
/// A simple ActionResult that causes a page crash to exemplify error handling.
/// </summary>
/// <returns></returns>
public ActionResult ErrorTest()
{
return View("ErrorTest");
}
}
}
26 changes: 19 additions & 7 deletions TakeHome/Controllers/FeedbackController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,36 @@

namespace TakeHome.Controllers
{
/// <summary>
/// Controller for Feedback form and related functionality.
/// </summary>
public class FeedbackController : Controller
{
// GET: Feedback

public ActionResult Index()
{
return View();
/// <summary>
/// Returns the form page directly.
/// </summary>
/// <returns></returns>
public ActionResult Index(FeedbackForm form) {
// If the form submitted sucessfully, redirect to the ThankYou page and passthrough the form data.
return Redirect("/Feedback/Feedback");
}

/// <summary>
/// Returns the Feedback (form) page.
/// </summary>
/// <param name="form">The form passed through to the page.</param>
/// <returns>Return the Feedback form page. If the form is being submitted and is properly filled out, it is routed to the ThankYou page.</returns>
[ValidateInput(true)]
public ActionResult Feedback(FeedbackForm form)
{
// If the form submitted sucessfully, redirect to the ThankYou page and passthrough the form data.
if (ModelState.IsValid)
{
return View("ThankYou", form);
}
else
ViewBag.Result = "Invalid Entries, Kindly Recheck.";


// If the page is not in a submission state, display the form.
return View();
}

Expand Down
20 changes: 11 additions & 9 deletions TakeHome/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@

namespace TakeHome.Controllers
{
/// <summary>
/// The Home controller.
/// </summary>
public class HomeController : Controller
{
/// <summary>
/// Returns the homepage.
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
return View();
}

public ActionResult About()
{
ViewBag.Message = "Your application description page.";

return View();
}

/// <summary>
/// Returns the Contact page.
/// </summary>
/// <returns></returns>
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
Expand Down
33 changes: 33 additions & 0 deletions TakeHome/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,38 @@ protected void Application_Start()
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}

/// <summary>
/// When an error is present, route is adjusted based on what the error is.
/// If the error
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
if(exception != null)
{
int errorStatusCode = 0;

if (exception is HttpException httpException)
{
errorStatusCode = httpException.GetHttpCode();
}

// Adjust the errorPath if the status code is in the 400 series. Otherwise, stick with the default.
if (errorStatusCode.ToString().StartsWith("4"))
{
var errorPath = "~/Error/NotFound";
// Rewrite the request URL to invoke the ErrorController
Response.TrySkipIisCustomErrors = true;
Response.Clear();
Server.ClearError();

Server.TransferRequest(errorPath, false);
}
}

}
}
}
3 changes: 2 additions & 1 deletion TakeHome/Instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Your front-end developer has provided the form markup in an html file. You need

Requirements:

- Create a new Feedback page and add it to the site header. The Feedback page should leverage the site layout. The body content area will contain the form markup provided by the front end team (see form.html).
- Create a new Feedback page and add it to the site header. The Feedback page should leverage the site layout.
The body content area will contain the form markup provided by the front end team (see form.html).
- Create a model for the form and a controller to process the form post.
- The form inputs must be validated.
- All fields are required.
Expand Down
20 changes: 20 additions & 0 deletions TakeHome/Models/Base.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace TakeHome.Models
{
/// <summary>
/// The base model which is inherited by other models.
/// </summary>
public class Base
{
/// <summary>
/// Determines if the page should be indexed for SEO. Defaults to true.
/// </summary>
public bool NoIndex { get; set; } = true;
}
}
21 changes: 21 additions & 0 deletions TakeHome/Models/Error.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace TakeHome.Models
{
/// <summary>
/// The Error model for displaying information related to the error pages.
/// </summary>
public class Error : Base
{
/// <summary>
/// A simple, unset property for causing an error on the ErrorTest page.
/// This is to showcase the error handling in the web.config.
/// </summary>
public bool ErrorTest { get; set; }
}
}
Loading