示例#1
0
        public void TestUserAssignAndRemoveRole()
        {
            var userID = new Random().Next(1, 10);

            var assignRole = new UserAssignRole(userID, ManagerType.DepositOfficer, 1);
            var removeManager = new RemoveManager(1, 1, 1);

            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(assignRole);
            });

            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(removeManager);
            });
        }
示例#2
0
        public ActionResult RemoveManager(int userId, int managerID)
        {
            if (managerID <= 0) return Json(new JsonResult(-1));

            try
            {
                var cmd = new RemoveManager(userId, managerID, this.CurrentUser.UserID);
                this.CommandBus.Send(cmd);
                return Json(JsonResult.Success);
            }
            catch (CommandExecutionException ex)
            {
                if (ex.ErrorCode == (int)ErrorCode.NoPermission)
                    return Json(new JsonResult(-3));
                else return Json(new JsonResult(ex.ErrorCode));
            }
        }