Exemplo n.º 1
0
        public ActionResult RemoveCharacter(long removeId, string authorizeRemove)
        {
            string message = string.Empty;

            if (string.IsNullOrWhiteSpace(authorizeRemove) || !removeId.ToString().Equals(authorizeRemove))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                string userId = User.Identity.GetUserId();
                ManageCharactersViewModel model = new ManageCharactersViewModel
                {
                    AuthedUser = UserManager.FindById(userId)
                };

                IPlayerTemplate character = model.AuthedUser.GameAccount.Characters.FirstOrDefault(ch => ch.Id.Equals(removeId));

                if (character == null)
                {
                    message = "That character does not exist";
                }
                else if (character.Remove(model.AuthedUser.GameAccount, model.AuthedUser.GetStaffRank(User)))
                {
                    message = "Character successfully deleted.";
                }
                else
                {
                    message = "Error. Character not removed.";
                }
            }

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
Exemplo n.º 2
0
        public ActionResult AddCharacter(ManageCharactersViewModel vModel)
        {
            string userId = User.Identity.GetUserId();
            ManageCharactersViewModel model = new ManageCharactersViewModel
            {
                AuthedUser   = UserManager.FindById(userId),
                ValidGenders = TemplateCache.GetAll <IGender>()
            };

            PlayerTemplate newChar = new PlayerTemplate
            {
                Name                = vModel.NewCharacter.Name,
                SurName             = vModel.NewCharacter.SurName,
                Gender              = vModel.NewCharacter.Gender,
                SuperSenses         = vModel.NewCharacter.SuperSenses,
                GamePermissionsRank = StaffRank.Player,
                Race                = vModel.NewCharacter.Race
            };

            if (User.IsInRole("Admin"))
            {
                newChar.GamePermissionsRank = vModel.NewCharacter.GamePermissionsRank;
            }

            string message = model.AuthedUser.GameAccount.AddCharacter(newChar);

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
Exemplo n.º 3
0
        public ActionResult RemoveCharacter(long ID, string authorize)
        {
            string message = string.Empty;

            if (string.IsNullOrWhiteSpace(authorize) || !ID.ToString().Equals(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                var userId = User.Identity.GetUserId();
                var model  = new ManageCharactersViewModel
                {
                    authedUser = UserManager.FindById(userId)
                };

                var character = model.authedUser.GameAccount.Characters.FirstOrDefault(ch => ch.ID.Equals(ID));

                if (character == null)
                {
                    message = "That character does not exist";
                }
                else if (character.Remove())
                {
                    message = "Character successfully deleted.";
                }
                else
                {
                    message = "Error. Character not removed.";
                }
            }

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
Exemplo n.º 4
0
        public ActionResult AddCharacter(string newName, string newSurName, string newGender, long raceId, StaffRank chosenRole = StaffRank.Player)
        {
            string message = string.Empty;
            var    userId  = User.Identity.GetUserId();
            var    model   = new ManageCharactersViewModel
            {
                authedUser = UserManager.FindById(userId)
            };

            var newChar = new Character();

            newChar.Name    = newName;
            newChar.SurName = newSurName;
            newChar.Gender  = newGender;
            var race = ReferenceWrapper.GetOne <Race>(raceId);

            if (race != null)
            {
                newChar.RaceData = race;
            }

            if (User.IsInRole("Admin"))
            {
                newChar.GamePermissionsRank = chosenRole;
            }
            else
            {
                newChar.GamePermissionsRank = StaffRank.Player;
            }

            message = model.authedUser.GameAccount.AddCharacter(newChar);

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
Exemplo n.º 5
0
        public ActionResult ManageCharacters(string message)
        {
            ViewBag.StatusMessage = message;

            var userId = User.Identity.GetUserId();
            var model  = new ManageCharactersViewModel
            {
                authedUser = UserManager.FindById(userId),
                ValidRoles = (StaffRank[])Enum.GetValues(typeof(StaffRank))
            };

            model.ValidRaces = ReferenceWrapper.GetAll <Race>();

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult ManageCharacters(string message)
        {
            ViewBag.StatusMessage = message;

            string userId = User.Identity.GetUserId();
            ManageCharactersViewModel model = new ManageCharactersViewModel
            {
                AuthedUser   = UserManager.FindById(userId),
                NewCharacter = new PlayerTemplate(),
                ValidGenders = TemplateCache.GetAll <IGender>()
            };

            model.ValidRaces = TemplateCache.GetAll <IRace>();

            return(View(model));
        }