public void Execute(int roleId, int[] stagesIds) { var existingRoleRouteStares = _executor.GetQuery <GetRoleRouteStageByRoleIdQyery>().Process(q => q.Execute(roleId)); _executor.CommandChain().AddCommand <DeleteRoleRouteStagesCommand>(c => c.Execute(existingRoleRouteStares, stagesIds)) .AddCommand <CreateRoleRouteStagesCommand>(c => c.Execute(existingRoleRouteStares, stagesIds, roleId)) .ExecuteAllWithTransaction(); }
public ViewResult Registration(UserRegistrationModel userRegistrationModel) { var user = userRegistrationModel.ToUser; _executor .CommandChain() .AddCommand <RegisterUserCommand>(c => c.Execute(user)) .AddCommand <CreateUserClaimCommand>(c => c.Execute(new UserClaimDto { UserId = user.Id, ClaimName = ClaimTypes.Name, ClaimValue = user.UserName })) .AddCommand <CreateUserClaimCommand>(c => c.Execute(new UserClaimDto { UserId = user.Id, ClaimName = ClaimTypes.Role, ClaimValue = "superadmin" })) .AddCommand <CreateUserClaimCommand>(c => c.Execute(new UserClaimDto { UserId = user.Id, ClaimName = ClaimTypes.Gender, ClaimValue = Enum.GetName(typeof(GenderType), userRegistrationModel.Gender) })) .ExecuteAllWithTransaction(); return(View(userRegistrationModel)); }