Esempio n. 1
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 });
        }
Esempio n. 2
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);
        }
Esempio n. 3
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 });
        }