コード例 #1
0
        public ProjectsMutationSpecification(ProjectCommonController projectManager)
        {
            Name = "ProjectsMutation";
            var safe = new Safe(_log);

            this.RequireAuthorization();
            Field <ProjectSpecification>(
                "insert",
                Description = "add a project",
                new QueryArguments(
                    new QueryArgument <ProjectCreateUpdateSpecification> {
                Name = Value
            }
                    ),
                safe.Wrap(context =>
            {
                var project = context.GetArgument <ProjectCreateUpdateModel>(Name = Value);
                return(projectManager.Insert(project));
            })).RequirePermission(Activity.UpdateProject);

            Field <ProjectSpecification>(
                "update",
                Description = "update a project",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id"
            },
                    new QueryArgument <ProjectCreateUpdateSpecification> {
                Name = Value
            }
                    ),
                safe.Wrap(context =>
            {
                var id      = context.GetArgument <string>(Name = "id");
                var project = context.GetArgument <ProjectCreateUpdateModel>(Name = Value);
                return(projectManager.Update(id, project));
            })).RequirePermission(Activity.UpdateProject);

            Field <BooleanGraphType>(
                "delete",
                Description = "permanently remove a project",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id"
            }
                    ),
                safe.Wrap(context =>
            {
                var id = context.GetArgument <string>(Name = "id");
                return(projectManager.Delete(id));
            })).RequirePermission(Activity.DeleteProject);
        }
コード例 #2
0
 public Task <ProjectModel> Update(string id, [FromBody] ProjectCreateUpdateModel model)
 {
     return(_projectCommonController.Update(id, model));
 }