示例#1
0
        public ActionResult EditCharacter(long id, AddEditCharacterViewModel vModel)
        {
            string          userId     = User.Identity.GetUserId();
            ApplicationUser authedUser = UserManager.FindById(userId);
            IPlayerTemplate obj        = PlayerDataCache.Get(new PlayerDataCacheKey(typeof(IPlayerTemplate), authedUser.GlobalIdentityHandle, id));

            obj.Name                = vModel.DataObject.Name;
            obj.SurName             = vModel.DataObject.SurName;
            obj.Gender              = vModel.DataObject.Gender;
            obj.SuperSenses         = vModel.DataObject.SuperSenses;
            obj.GamePermissionsRank = vModel.DataObject.GamePermissionsRank;
            obj.Race                = vModel.DataObject.Race;
            string message;

            if (obj == null)
            {
                message = "That character does not exist";
            }
            else
            {
                if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.Log("*WEB* - EditCharacter[" + authedUser.GameAccount.GlobalIdentityHandle + "]", LogChannels.AccountActivity);
                    message = "Edit Successful.";
                }
                else
                {
                    message = "Error; edit failed.";
                }
            }

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
示例#2
0
        public ActionResult EditCharacter(long id)
        {
            string          userId = User.Identity.GetUserId();
            ApplicationUser user   = UserManager.FindById(userId);

            IPlayerTemplate           obj   = PlayerDataCache.Get(new PlayerDataCacheKey(typeof(IPlayerTemplate), user.GlobalIdentityHandle, id));
            AddEditCharacterViewModel model = new AddEditCharacterViewModel
            {
                AuthedUser   = user,
                DataObject   = obj,
                ValidRaces   = TemplateCache.GetAll <IRace>(),
                ValidGenders = TemplateCache.GetAll <IGender>()
            };

            return(View(model));
        }
示例#3
0
        public bool AddCharacter(out Character newCharacter)
        {
            bool ret = false;

            newCharacter = null;
            AddEditCharacterViewModel vm     = new AddEditCharacterViewModel(new Character(), CharacterViewMode.Add);
            AddEditCharacter          window = new AddEditCharacter(vm);

            vm.SavedClicked = new Action(() => window.Close());

            window.ShowDialog();

            if (vm.SavedSelected == true)
            { // Save
                ret = SouthParkViewModelFactory.GetInstance().CharacterProvider.AddCharacter(vm.TargetCharacter);

                newCharacter = vm.TargetCharacter;
            }

            return(ret);
        }
示例#4
0
        public bool EditCharacter(Character selectedCharacter)
        {
            bool      ret  = false;
            Character temp = new Character();

            MiscUtilities.Copy(temp, selectedCharacter);

            AddEditCharacterViewModel vm     = new AddEditCharacterViewModel(temp, CharacterViewMode.Edit);
            AddEditCharacter          window = new AddEditCharacter(vm);

            vm.SavedClicked = new Action(() => window.Close());

            window.ShowDialog();

            if (vm.SavedSelected == true)
            { // Save
                ret = SouthParkViewModelFactory.GetInstance().CharacterProvider.UpdateCharacter(selectedCharacter, vm.TargetCharacter);
            }

            return(ret);
            //MessageBox.Show($"Edit : {selectedCharacter.FirstName}");
        }
 public AddEditCharacter(AddEditCharacterViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }