public async Task <IActionResult> Delete([FromQuery] Delete.Command model) { await Mediator.Send(model); return(NoContent()); }
public async Task<IHttpActionResult> Delete(int id) { // Return a bad request if the query url has no id if (id == 0) return BadRequest("id cannot be empty"); // Create a command based on the entity id from the url var command = new Delete.Command() { Id = id }; // Send an async request through the mediator await _mediator.SendAsync(command); // Return the id of the deleted entity return Ok(id); }
public async Task <ActionResult <Unit> > Delete(Guid id, Delete.Command command) { return(await _mediator.Send(new Delete.Command { Id = id })); }
public async Task DeleteTest_ValidData_ExpectSuccess() { //create a test Article var articleCmd = new Conduit.Features.Articles.Create.Command() { Article = new Conduit.Features.Articles.Create.ArticleData() { Title = "Test article dsergiu77", Description = "Description of the test article", Body = "Body of the test article", TagList = new string[] { "tag1", "tag2" } } }; //save it var article = await Articles.ArticleHelpers.CreateArticle(this, articleCmd); //create a test category var categoryCmd = new Conduit.Features.Categories.Create.Command() { Category = new Conduit.Features.Categories.Create.CategoryData() { ParentCategory = 0, Name = "TestCategory", Description = "This is a test Category" } }; //save it var createdCategory = await Categories.CategoryHelpers.CreateCategory(this, categoryCmd); //assign the article to the category var createCmd = new Create.Command() { articleCategory = new Domain.ArticleCategory() { ArticleCategoryId = 0, ArticleId = 1, CategoryId = 1, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } }; //save the assignment var createdArticleCategory = await ArticleCategoryHelpers.CreateArticleCategory(this, createCmd); var articleCategoryId = createdArticleCategory.ArticleCategoryId; //delete created article var deleteCmd = new Delete.Command(articleCategoryId); var dbContext = GetDbContext(); var categoryDeleteHandler = new Delete.QueryHandler(dbContext); await categoryDeleteHandler.Handle(deleteCmd, new System.Threading.CancellationToken()); var dbArticle = await ExecuteDbContextAsync(db => db.ArticleCategories.Where(d => d.ArticleCategoryId == deleteCmd.ArticleCategoryId).SingleOrDefaultAsync()); Assert.Null(dbArticle); }
public async Task <Delete.Response> Delete([FromRoute] Delete.Command command) { var response = await _mediator.Send(command); return(response); }
public async Task <ActionResult <Unit> > Delete([FromRoute] Delete.Command command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> Delete(Delete.Command command) { await _mediator.Send(command); return(Ok()); }
public async Task <ActionResult> Delete(Delete.Command model) { await _mediator.SendAsync(model); return(this.RedirectToActionJson("Index")); }
public async Task <ActionResult <Unit> > Delete(Guid id, Delete.Command command) { command.Id = id; return(await _mediator.Send(command)); }
public async Task <ActionResult> Delete([FromRoute] Delete.Command command) => await _mediator.Send(command);
public async Task <object> Delete(Guid id) { var cmd = new Delete.Command(id, User.Identifier()); return(await _mediator.Send(cmd)); }
public async Task <ActionResult <Unit> > Delete(Delete.Command command) { return(await _mediator.Send(command)); }
public RootMutation(IMediator mediator) { this.Name = "Mutation"; this.Description = "The system root mutation"; #region Users Mutations //Add User FieldAsync <UserType>( name: "addUser", description: "This mutation add a user", arguments: new QueryArguments { new QueryArgument <NonNullGraphType <UserInputType> >() { Name = "Input", Description = "A system user" } }, resolve: async(context) => { var input = context.GetArgument <Register.Command>("Input"); /* * Register.Command command = new Register.Command() * { * Age = input.Age, * Email = input.Email, * Name = input.Name * }; */ var result = await mediator.Send(input); return(result); }); FieldAsync <BooleanGraphType>( name: "removeUser", description: "This mutation add a user", arguments: new QueryArguments { new QueryArgument <NonNullGraphType <IdGraphType> >() { Name = "Id", Description = "A user id" } }, resolve: async(context) => { var id = context.GetArgument <Guid>("Id"); var command = new Delete.Command() { Id = id }; await mediator.Send(command); return(true); }); #endregion }