summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:22:50 -0700
committermatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:22:50 -0700
commit5801934047775998a4ba670acfeb8367e06e588b (patch)
treed9268d569953c32271bf2f31a5362531481aed88
parent180d8ac483c8879fa5170928b406d6a325a4057f (diff)
small cleanup of WelcomeController
-rw-r--r--LHSCamp/LHSCamp/Controllers/WelcomeController.cs44
1 files changed, 17 insertions, 27 deletions
diff --git a/LHSCamp/LHSCamp/Controllers/WelcomeController.cs b/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
index a3a7352..4b2ad2a 100644
--- a/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
+++ b/LHSCamp/LHSCamp/Controllers/WelcomeController.cs
@@ -15,17 +15,18 @@ namespace LHSCamp.Controllers
public ActionResult Candidate()
{
var user = db.Users.Find(User.Identity.GetUserId());
- if (user == null || !user.IsCandidate)
+ if (user == null)
{
- return RedirectToAction("Index", "Home");
+ return RedirectToAction("GetClass", "Candidates");
}
- ViewBag.Id = user.Candidate.Id;
+ ViewBag.Id = user.Id;
ViewBag.Confirmed = user.IsConfirmed;
ViewBag.Email = user.Email;
- ViewBag.Position = user.Candidate.Position;
- ViewBag.Reasons = user.Candidate.Reasons ?? string.Empty;
+ ViewBag.Position = user.Position;
+ ViewBag.Reasons = user.Platform ?? string.Empty;
+
if (TempData.ContainsKey("Uploaded"))
{
ViewBag.Uploaded = (bool)TempData["Uploaded"];
@@ -61,12 +62,12 @@ namespace LHSCamp.Controllers
Directory.CreateDirectory(imagesFolder);
// Remove the existing picture and log an image change
- if (isProfile && candidate.Candidate.ProfilePic != null)
+ if (isProfile && candidate.ProfilePicture != null)
{
- var oldPic = Server.MapPath("~" + candidate.Candidate.ProfilePic);
+ var oldPic = Server.MapPath("~" + candidate.ProfilePicture);
System.IO.File.Delete(oldPic);
- var entry = candidate.Candidate.ProfilePic;
+ var entry = candidate.ProfilePicture;
var currLog = db.Log.FirstOrDefault(log => log.Type == "Image Changed/Removed" && log.Entry == entry);
if (currLog == null)
{
@@ -77,12 +78,12 @@ namespace LHSCamp.Controllers
});
}
}
- else if (!isProfile && candidate.Candidate.CoverPhoto != null)
+ else if (!isProfile && candidate.CoverPhoto != null)
{
- var oldPic = Server.MapPath("~" + candidate.Candidate.CoverPhoto);
+ var oldPic = Server.MapPath("~" + candidate.CoverPhoto);
System.IO.File.Delete(oldPic);
- var entry = candidate.Candidate.CoverPhoto;
+ var entry = candidate.CoverPhoto;
var currLog = db.Log.FirstOrDefault(log => log.Type == "Image Changed/Removed" && log.Entry == entry);
if (currLog == null)
{
@@ -97,11 +98,11 @@ namespace LHSCamp.Controllers
file.SaveAs(path); // Upload the new pic
if (isProfile)
{
- candidate.Candidate.ProfilePic = "/Content/Images/Candidates/" + candidate.Id + extension;
+ candidate.ProfilePicture = "/Content/Images/Candidates/" + candidate.Id + extension;
}
else
{
- candidate.Candidate.CoverPhoto = "/Content/Images/Covers/" + candidate.Id + extension;
+ candidate.CoverPhoto = "/Content/Images/Covers/" + candidate.Id + extension;
}
db.SaveChanges();
return true;
@@ -116,12 +117,7 @@ namespace LHSCamp.Controllers
return HttpNotFound();
}
- if (!user.IsCandidate)
- { // Only candidates can upload profile pictures
- return RedirectToAction("Index", controllerName: "Home");
- }
-
- this.UploadPicture(file, user, "~/Content/Images/Candidates/", true);
+ UploadPicture(file, user, "~/Content/Images/Candidates/", true);
TempData["Uploaded"] = true; // Not the best way to do this, but it'll do for now
return RedirectToAction("Candidate", controllerName: "Welcome");
@@ -130,15 +126,9 @@ namespace LHSCamp.Controllers
[HttpPost]
public ActionResult UploadCover(HttpPostedFileBase file)
{
- var userId = User.Identity.GetUserId();
- var user = db.Users.Find(userId);
-
- if (!user.IsCandidate)
- {
- return RedirectToAction("Index", controllerName: "Home");
- }
+ var user = db.Users.Find(User.Identity.GetUserId());
- this.UploadPicture(file, user, "~/Content/Images/Covers/", false);
+ UploadPicture(file, user, "~/Content/Images/Covers/", false);
TempData["Uploaded"] = true;
return RedirectToAction("Candidate", controllerName: "Welcome");
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback