public void RemoveRole([FromBody] RemoveRoleRequestModel requestModel)
        {
            var existingRole = Context.Roles.Include(r => r.RoleMembers).FirstOrDefault(r => r.RoleId == requestModel.RoleId);

            if (existingRole != null)
            {
                Context.Roles.Remove(existingRole);
                Context.SaveChanges();
            }
        }
        public void RemoveRole_Successful()
        {
            // Given
            var resources    = new Resources();
            var requestModel = new RemoveRoleRequestModel {
                RoleId = 1
            };

            resources.MockApiCaller.AddMockResponse("WebApi:Role:RemoveRole", requestModel, "Success");

            // When
            var result = resources.Controller.RemoveRole(requestModel) as JsonResult;

            // Then
            Assert.IsNotNull(result);
            Assert.AreEqual("Success", result.Value.ToString());
        }
Ejemplo n.º 3
0
        public void RemoveRole()
        {
            var resources = new Resources();

            using (resources.Context.Database.BeginTransaction())
            {
                // Given
                var role         = TestHelper.CreateRole(resources.Context);
                var requestModel = new RemoveRoleRequestModel {
                    RoleId = role.RoleId
                };

                // When
                resources.Controller.RemoveRole(requestModel);

                // Then
                var savedRole = resources.Context.Roles.FirstOrDefault(r => r.RoleId == requestModel.RoleId);
                Assert.IsNull(savedRole);
            }
        }
        public JsonResult RemoveRole(RemoveRoleRequestModel requestModel)
        {
            WebApiCaller.PostAsync <string>("WebApi:Role:RemoveRole", requestModel);

            return(Json("Success"));
        }