Ejemplo n.º 1
0
        public ActionResult Schedule(ScheduleRaidModel model)
        {
            if (!Manager.IsReallyAuthenticated(Request))
                return RedirectToAction("LogOn", "Account");

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

            if(model.Name.Length > 100)
                return new JsonResult() { Data = new RaidResponse(false, "The name cannot be more than 100 characters long.") };

            if (model.Description.Length > 1000)
                return new JsonResult() { Data = new RaidResponse(false, "The description cannot be more than 1000 characters long.") };

            var instance = new RaidInstance()
            {
                Raid = model.Raid,
                Name = model.Name,
                Description = model.Description,
                InviteTime = model.InviteTime,
                StartTime = model.StartTime,
                Archived = false
            };

            string errorMsg;

            if (!RaidInstance.Store.TryCreate(instance, out errorMsg))
                return new JsonResult() { Data = new RaidResponse(false, errorMsg) };

            return new JsonResult() { Data = new RaidResponse(true, "Hi!") };
        }
Ejemplo n.º 2
0
        public bool Initialize()
        {
            _raidInstance = RaidInstance.Store.ReadOneOrDefault(ri => ri.ID == ID);

            if (null == _raidInstance)
                return false;

            _signups = RaidSignup.Store.ReadAll(ID);
            _raid = Raid.Store.ReadOneOrDefault(r => r.Name == _raidInstance.Raid);

            return true;
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int ID, ScheduleRaidModel model)
        {
            if (!Manager.IsReallyAuthenticated(Request))
                return RedirectToAction("LogOn", "Account");

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

            if (model.Name.Length > 100)
                return new JsonResult() { Data = new RaidResponse(false, "The name cannot be more than 100 characters long.") };

            if (model.Description.Length > 1000)
                return new JsonResult() { Data = new RaidResponse(false, "The description cannot be more than 1000 characters long.") };

            if (null == RaidInstance.Store.ReadOneOrDefault(ri => ri.ID == ID))
                return new JsonResult() { Data = new RaidResponse(false, "Invalid raid instance ID provided for editing a raid instance.") };

            var raidInstance = new RaidInstance()
            {
                ID = ID,
                Raid = model.Raid,
                Name = model.Name,
                Description = model.Description,
                InviteTime = model.InviteTime,
                StartTime = model.StartTime
            };

            string errorMsg;

            if (!RaidInstance.Store.TryModify(raidInstance, out errorMsg))
                return new JsonResult() { Data = new RaidResponse(false, errorMsg) };

            return new JsonResult() { Data = new RaidResponse(true, "") };
        }