summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:26:25 -0700
committermatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:26:25 -0700
commit13fb814d375c15fa559209251a71fe43bd9edaab (patch)
tree8b83b02a18cc885e9fa3845021d7bbdb06197add
parent5801934047775998a4ba670acfeb8367e06e588b (diff)
added a viewmodel for candidates welcome
-rw-r--r--LHSCamp/LHSCamp/Controllers/WelcomeController.cs15
-rw-r--r--LHSCamp/LHSCamp/Models/CandidateViewModel.cs3
-rw-r--r--LHSCamp/LHSCamp/Views/Welcome/Candidate.cshtml22
3 files changed, 20 insertions, 20 deletions
diff --git a/LHSCamp/LHSCamp/Controllers/WelcomeController.cs b/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
index 4b2ad2a..692b823 100644
--- a/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
+++ b/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
@@ -1,7 +1,9 @@
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Web;
using System.Web.Mvc;
+using AutoMapper;
using LHSCamp.Models;
using Microsoft.AspNet.Identity;
@@ -14,18 +16,13 @@ namespace LHSCamp.Controllers
public ActionResult Candidate()
{
- var user = db.Users.Find(User.Identity.GetUserId());
- if (user == null)
+ var candidate = db.Users.Find(User.Identity.GetUserId());
+ if (candidate == null)
{
return RedirectToAction("GetClass", "Candidates");
}
- ViewBag.Id = user.Id;
-
- ViewBag.Confirmed = user.IsConfirmed;
- ViewBag.Email = user.Email;
- ViewBag.Position = user.Position;
- ViewBag.Reasons = user.Platform ?? string.Empty;
+ var model = Mapper.Map<Candidate, CandidateViewModel>(candidate);
if (TempData.ContainsKey("Uploaded"))
{
@@ -36,7 +33,7 @@ namespace LHSCamp.Controllers
ViewBag.Uploaded = false;
}
- return View();
+ return View(model);
}
// Thanks! http://stackoverflow.com/questions/5193842/file-upload-asp-net-mvc-3-0
diff --git a/LHSCamp/LHSCamp/Models/CandidateViewModel.cs b/LHSCamp/LHSCamp/Models/CandidateViewModel.cs
index c0845b2..3894698 100644
--- a/LHSCamp/LHSCamp/Models/CandidateViewModel.cs
+++ b/LHSCamp/LHSCamp/Models/CandidateViewModel.cs
@@ -18,5 +18,8 @@ namespace LHSCamp.Models
public string Platform { get; set; }
public ICollection<ExternalLink> ExternalLinks { get; set; }
+
+ public bool IsConfirmed { get; set; }
+ public string Email { get; set; }
}
} \ No newline at end of file
diff --git a/LHSCamp/LHSCamp/Views/Welcome/Candidate.cshtml b/LHSCamp/LHSCamp/Views/Welcome/Candidate.cshtml
index 54ad711..35e4eff 100644
--- a/LHSCamp/LHSCamp/Views/Welcome/Candidate.cshtml
+++ b/LHSCamp/LHSCamp/Views/Welcome/Candidate.cshtml
@@ -13,11 +13,11 @@
<img src="~/Content/Images/logo.blue.png" alt="lhs|campaign" id="logo" />
<a href="~/Account/LogOff">log out</a>
- <a target="_blank" href="~/Candidates/@(ViewBag.Id)">view your profile</a>
+ <a target="_blank" href="~/Candidates/@(Model.Id)">view your profile</a>
</header>
<div style="position: relative; width: 800px; margin: 0 auto;">
<h1>Welcome to LHS Campaign!</h1>
- @if (!ViewBag.Confirmed)
+ @if (!Model.IsConfirmed)
{
<span>
We'll run through a few quick questions to get your candidate account set up.
@@ -25,23 +25,23 @@
you'll be allowed to upload your profile image and be featured on LHS Campaign.
</span>
}
- @if (ViewBag.Uploaded != null && ViewBag.Uploaded == true)
+ @if (ViewBag.Uploaded)
{
<span>
- Image uploaded! Click <a target="_blank" href="~/Candidates/@(ViewBag.Id)">here</a> to view your profile.
+ Image uploaded! Click <a target="_blank" href="~/Candidates/@(Model.Id)">here</a> to view your profile.
</span>
<script type="text/javascript">
- window.open("/Candidates/@(ViewBag.Id)");
+ window.open("/Candidates/@(Model.Id)");
</script>
}
<br />
<br />
<div id="tabs">
- <div class="@((ViewBag.Uploaded != null && ViewBag.Uploaded == true) ? "" : "selected")">email</div>
+ <div class="@(ViewBag.Uploaded ? "" : "selected")">email</div>
<div>position</div>
<div>campaign</div>
<div>social</div>
- @if (ViewBag.Uploaded != null && ViewBag.Uploaded == true)
+ @if (ViewBag.Uploaded)
{
<div class="selected">picture</div>
}
@@ -54,11 +54,11 @@
<div class="tab-content" data-tab="email">
<h2>Voters will be able to see this email, so think twice before using a personal address.</h2>
- <input type="email" id="email-input" placeholder="email" value="@(ViewBag.Email)" />
+ <input type="email" id="email-input" placeholder="email" value="@(Model.Email)" />
<button id="update-email">Save</button>
- @if (!ViewBag.Confirmed)
+ @if (!Model.IsConfirmed)
{
@:We'll contact you within 24 hours to confirm your email and give you a rundown of the final step before you're listed as a candidate.
}
@@ -70,7 +70,7 @@
<select id="position" class="default-input standard-input" style="margin-top: 20px; width: 333px; height: 50px; padding-right: -50px;">
@foreach (var pos in new string[] { "Secretary", "Treasurer", "Vice President", "President" })
{
- if (pos == ViewBag.Position)
+ if (pos == Model.Position)
{
<option selected>@pos</option>
}
@@ -102,7 +102,7 @@
</div>
<div class="tab-content" data-tab="picture">
- @if (ViewBag.Confirmed)
+ @if (Model.IsConfirmed)
{
@:Pictures must be less than 4MB in size and have a .jpg, .png, or .gif extension.
<br /><br />
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback