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);
        }
Exemplo n.º 2
0
 public Task <ProjectModel> Insert([FromBody] ProjectCreateUpdateModel model)
 {
     return(_projectCommonController.Insert(model));
 }