Esempio n. 1
0
        public ActionResult ApproveApp(AuthUserCharacterGuildApplication application)
        {
            string username = User.Identity.GetUserId();
            // Add the user to the guild roster, then remove the application
            var app         = _authUserCharacterGuildApplicationRepository.GetPendingApplication(application.Id);
            var defaultRank = _guildRankRepository.GetDefaultRankForGuildApplications();

            if (defaultRank == null)
            {
                ModelState.AddModelError("", "Couldn't approve this guild application because no rank has been defined as default for new members!");
                return(View(app));
            }
            var result = _authUserCharacterRepository.AddCharacterToGuild(app.AuthUserCharacterId, app.GuildId, defaultRank.Id);

            if (!result.Success)
            {
                ModelState.AddModelError("", result.Message);
                return(View(app));
            }
            _logger.Debug(string.Format("{0} has approved {1}'s application for {2}", username, app.Character.CharacterName, app.Guild.Name));
            result = _authUserCharacterGuildApplicationRepository.Remove(application.Id, username);
            if (!result.Success)
            {
                ModelState.AddModelError("", result.Message);
                return(View(app));
            }
            return(RedirectToAction("AppApproved", new { @id = app.GuildId }));
        }
Esempio n. 2
0
        public ActionResult RemoveCharacter(AuthUserCharacter model)
        {
            string username = User.Identity.GetUserId();

            // Check if the character has uploaded any logs or created any sessions. If so, we need to set them to 'removed', not remove them.

            // If there are pending guild applications, remove them
            var pendingGuildApplication = _authUserCharacterGuildApplicationRepository.GetPendingApplicationForCharacter(model.Id);

            if (pendingGuildApplication != null)
            {
                _authUserCharacterGuildApplicationRepository.Remove(pendingGuildApplication.Id, username);
            }

            // Now, remove the user
            var result = _authUserCharRepository.Delete(username, model.Id);

            if (result.Success)
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", result.Message);

            return(View(model));
        }