public async Task <ActionResult> RemoveModerator(int id)
        {
            var cmd      = new RemoveModeratorByRecordIDCommand(id, true).SetUserContext(User);
            var response = await cmd.Execute();

            if (response.Success)
            {
                return(RedirectToAction("SubverseModerators"));
            }
            else
            {
                ModelState.AddModelError("", response.Message);
                if (response.Response.SubverseModerator != null)
                {
                    var model = new SubverseModerator()
                    {
                        ID       = response.Response.SubverseModerator.ID,
                        Subverse = response.Response.SubverseModerator.Subverse,
                        UserName = response.Response.SubverseModerator.UserName,
                        Power    = response.Response.SubverseModerator.Power
                    };
                    SetNavigationViewModel(model.Subverse);
                    return(View("~/Views/Subverses/Admin/RemoveModerator.cshtml", model));
                }
                else
                {
                    //bail
                    return(RedirectToAction("SubverseModerators"));
                }
            }
        }
        public async Task ModeratorRemovals_Allowed_Owner()
        {
            string subName = "testAllowedOwner";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorByRecordIDCommand          cmd      = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string baseUserName   = "";
            string originUserName = "";
            string targetUserName = "";


            originUserName = "******";
            targetUserName = "******";
            var user = TestHelper.SetPrincipal(originUserName);

            cmd      = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Success, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Success, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }
        public async Task ModeratorRemovals_Denials_System()
        {
            string subName = "testSystemDenials";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorByRecordIDCommand          cmd      = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string originUserName = "";
            string targetUserName = "";

            originUserName = "******";
            targetUserName = "******";
            var user = TestHelper.SetPrincipal(originUserName);

            cmd      = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }
        public async Task ModeratorRemovals_Denials_NonOwner()
        {
            string subName = "testDenials";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorByRecordIDCommand          cmd      = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string baseUserName   = "";
            string originUserName = "";
            string targetUserName = "";

            //Test same level drops
            baseUserName   = "******";
            originUserName = $"{baseUserName}-0";
            targetUserName = $"{baseUserName}-1";
            var user = TestHelper.SetPrincipal(originUserName);

            cmd      = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}-0";
            targetUserName = $"{baseUserName}-1";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}-0";
            targetUserName = $"{baseUserName}-1";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}-0";
            targetUserName = $"{baseUserName}-1";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            //Test L1 denials
            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            user           = TestHelper.SetPrincipal(originUserName);
            cmd            = new RemoveModeratorByRecordIDCommand(mods[targetUserName].ID, false).SetUserContext(user);
            response       = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }