Exemplo n.º 1
0
        //
        // GET: /Raid/Signup?ID=<ID>
        public ActionResult Signup(int ID)
        {
            var raidDetails = new RaidDetails(ID);

            if (!raidDetails.Initialize())
                return RedirectToAction("Index", "Home");

            ViewBag.RaidDetails = raidDetails;

            if (null == raidDetails.Signups)
            {
                ViewBag.NumRostered = 0;
                ViewBag.NumQueued = 0;
                ViewBag.NumCancelled = 0;
                ViewBag.NumTotal = 0;
                ViewBag.PercentageRostered = 0;
                ViewBag.PercentageQueued = 0;
                ViewBag.PercentageCancelled = 0;
            }
            else
            {
                ViewBag.NumTotal = raidDetails.Signups.Count;
                ViewBag.NumCancelled = raidDetails.Signups.FindAll(s => s.IsCancelled).Count;
                ViewBag.NumQueued = raidDetails.Signups.FindAll(s => !s.IsCancelled && !s.IsRostered).Count;
                ViewBag.NumRostered = raidDetails.Signups.FindAll(s => s.IsRostered).Count;
                ViewBag.PercentageRostered = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumRostered / ViewBag.NumTotal) * 100);
                ViewBag.PercentageQueued = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumQueued / ViewBag.NumTotal) * 100);
                ViewBag.PercentageCancelled = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumCancelled / ViewBag.NumTotal) * 100);
            }

            return View();
        }
Exemplo n.º 2
0
        public ActionResult Roster(int ID)
        {
            if (!Manager.IsReallyAuthenticated(Request))
                return RedirectToAction("LogOn", "Account");

            if (!Manager.GetCurrentUser().IsAdmin)
                return RedirectToAction("Index", "Home");

            var raidDetails = new RaidDetails(ID);

            if (!raidDetails.Initialize())
                return RedirectToAction("Index", "Home");

            ViewBag.RaidDetails = raidDetails;

            var tankSignups = new List<RaidSignup>();
            var healerSignups = new List<RaidSignup>();
            var rangedSignups = new List<RaidSignup>();
            var meleeSignups = new List<RaidSignup>();

            foreach(var signup in raidDetails.Signups)
            {
                var character = Character.Store.ReadOneOrDefault(c => c.Name == signup.Character);
                var specialization = Specialization.Store.ReadOneOrDefault(s => s.ID == (1 == signup.RosteredSpecialization ? character.PrimarySpecialization : character.SecondarySpecialization));

                if ("Tank" == specialization.Role)
                    tankSignups.Add(signup);
                else if ("Healer" == specialization.Role)
                    healerSignups.Add(signup);
                else if ("Ranged" == specialization.Role)
                    rangedSignups.Add(signup);
                else
                    meleeSignups.Add(signup);
            }

            ViewBag.TankSignups = tankSignups;
            ViewBag.HealerSignups = healerSignups;
            ViewBag.RangedSignups = rangedSignups;
            ViewBag.MeleeSignups = meleeSignups;

            if (null == raidDetails.Signups)
            {
                ViewBag.NumRostered = 0;
                ViewBag.NumQueued = 0;
                ViewBag.NumCancelled = 0;
                ViewBag.NumTotal = 0;
                ViewBag.PercentageRostered = 0;
                ViewBag.PercentageQueued = 0;
                ViewBag.PercentageCancelled = 0;
            }
            else
            {
                ViewBag.NumTotal = raidDetails.Signups.Count;
                ViewBag.NumCancelled = raidDetails.Signups.FindAll(s => s.IsCancelled).Count;
                ViewBag.NumQueued = raidDetails.Signups.FindAll(s => !s.IsCancelled && !s.IsRostered).Count;
                ViewBag.NumRostered = raidDetails.Signups.FindAll(s => s.IsRostered).Count;
                ViewBag.PercentageRostered = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumRostered / ViewBag.NumTotal) * 100);
                ViewBag.PercentageQueued = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumQueued / ViewBag.NumTotal) * 100);
                ViewBag.PercentageCancelled = 0 == ViewBag.NumTotal ? 0 : (int)((ViewBag.NumCancelled / ViewBag.NumTotal) * 100);
            }

            return View();
        }