示例#1
0
 public Task <UserModel> Register([FromBody] RegisterModel user)
 {
     return(_userCommonController.Register(user));
 }
示例#2
0
        public UsersMutationSpecification(UserCommonController userManager)
        {
            Name = "UsersMutation";
            var safe = new Safe(_log);

            Field <UserSpecification>(
                "insert",
                Description = "add a user",
                new QueryArguments(
                    new QueryArgument <UserCreateUpdateSpecification> {
                Name = Value
            }
                    ), safe.Wrap(context =>
            {
                var user = context.GetArgument <UserCreateUpdateModel>(Name = Value);
                return(userManager.Insert(user));
            })).RequirePermission(Activity.UpdateUsers);

            Field <UserSpecification>(
                "register",
                Description = "register a new user",
                new QueryArguments(
                    new QueryArgument <RegisterSpecification> {
                Name = Value
            }
                    ), safe.Wrap(context =>
            {
                var user = context.GetArgument <RegisterModel>(Name = Value);
                return(userManager.Register(user));
            }));

            Field <UserSpecification>(
                "update",
                Description = "update a user",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id"
            },
                    new QueryArgument <UserCreateUpdateSpecification> {
                Name = Value
            }
                    ), safe.Wrap(context =>
            {
                var id   = context.GetArgument <string>(Name = "id");
                var user = context.GetArgument <UserCreateUpdateModel>(Name = Value);
                return(userManager.Update(id, user));
            })).RequirePermission(Activity.UpdateUsers);

            Field <BooleanGraphType>(
                "delete",
                Description = "permanently remove a user",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id"
            }
                    ), safe.Wrap(context =>
            {
                var id = context.GetArgument <string>(Name = "id");
                return(userManager.Delete(id));
            })).RequirePermission(Activity.DeleteUser);
        }