summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:20:33 -0700
committermatthewsotoudeh <matthewsot@outlook.com>2015-04-26 11:20:33 -0700
commit180d8ac483c8879fa5170928b406d6a325a4057f (patch)
tree64af5804b2c5405d3f4525dee9487b09ff4e8438
parent125da794a4ef47976ac15fb457bf14a9d300482a (diff)
removed Homecontroller
-rw-r--r--LHSCamp/LHSCamp/Controllers/DefaultController.cs9
-rw-r--r--LHSCamp/LHSCamp/Controllers/HomeController.cs77
2 files changed, 4 insertions, 82 deletions
diff --git a/LHSCamp/LHSCamp/Controllers/DefaultController.cs b/LHSCamp/LHSCamp/Controllers/DefaultController.cs
index 1e8943f..94ce5b2 100644
--- a/LHSCamp/LHSCamp/Controllers/DefaultController.cs
+++ b/LHSCamp/LHSCamp/Controllers/DefaultController.cs
@@ -6,12 +6,11 @@ namespace LHSCamp.Controllers
{
public ActionResult Index()
{
- if (User.Identity.IsAuthenticated)
- {
- return RedirectToAction("Candidate", controllerName: "Welcome");
- }
- return RedirectToAction("Index", controllerName: "Home");
+ return User.Identity.IsAuthenticated ?
+ RedirectToAction("Candidate", controllerName: "Welcome") :
+ RedirectToAction("GetClass", controllerName: "Candidates");
}
+
[Route("GPlus")]
public ActionResult GPlus()
{
diff --git a/LHSCamp/LHSCamp/Controllers/HomeController.cs b/LHSCamp/LHSCamp/Controllers/HomeController.cs
deleted file mode 100644
index 07e65df..0000000
--- a/LHSCamp/LHSCamp/Controllers/HomeController.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using LHSCamp.Models;
-using Microsoft.AspNet.Identity;
-using System.Web.Mvc;
-
-namespace LHSCamp.Controllers
-{
- public class HomeController : Controller
- {
- // GET: Home
- public ActionResult Index(int? @class)
- {
- if (User.Identity.IsAuthenticated)
- {
- using (var db = new LCDB())
- {
- var user = db.Users.Find(User.Identity.GetUserId());
- if (user.IsCandidate || user.Candidate != null)
- {
- return RedirectToAction("Candidate", "Welcome");
- }
- }
- }
-
- var cookie = Request.Cookies["selected-class"];
- if (cookie != null && @class == null)
- {
- @class = int.Parse(cookie.Value);
- }
- else if (@class == null)
- {
- @class = 2017;
- }
-
- @class = (int)Math.Floor((decimal)@class);
- if (@class < 2016 || @class > 2018)
- {
- @class = 2017;
- }
- ViewBag.Year = @class;
- Response.Cookies.Set(new HttpCookie("selected-class", @class.ToString()));
-
- using (var db = new LCDB())
- {
- var positions = db.Users
- .Where(user => user.IsConfirmed && user.Candidate != null && user.GraduationYear == @class)
- .Select(user => user.Candidate)
- .GroupBy(cand => cand.Position.ToLower())
- .ToDictionary(c => c.Key, c => c.ToList());
-
- var finalPositions = new Dictionary<string, List<Candidate>>();
-
- foreach (var position in positions)
- {
- if (
- !(new[] {"secretary", "treasurer", "vice president", "president"}.Contains(
- position.Key)))
- {
- continue;
- }
- var rand = new Random();
- var candidates = position.Value.Where(candidate => candidate.ProfilePic != null).OrderBy(a => rand.Next()).ToList();
- foreach (var cand in candidates)
- {
- cand.ToString();
- }
- finalPositions.Add(position.Key, candidates);
- }
-
- return View(finalPositions);
- }
- }
- }
-} \ No newline at end of file
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback