public async Task <ICommandResult> Handle(CategoryDeleteCommand command) { //FFV command.Validate(); if (command.Invalid) { return(new GenericCommandResult( false, HttpStatusCode.BadRequest, command.Notifications)); } var _verify = await _categoryRepository.FindById(command.Id); if (_verify == null) { return(new GenericCommandResult(false, HttpStatusCode.NotFound, "Não localizado na base")); } var _entity = new Category { Id = command.Id }; var _result = await _cudRepository.Delete(_entity); //retorna o resultado if (!_result) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result)); } return(new GenericCommandResult(true, HttpStatusCode.OK, _result)); }
public IActionResult Delete([FromBody] CategoryDeleteDto categoryDeleteDto) { CategoryDeleteCommand categoryDeleteCommand = MapService.Map(categoryDeleteDto); Result result = _messages.Dispatch(categoryDeleteCommand); return(FromResult(result)); }
public async Task <GenericCommandResult> DeleteCategory( //[FromBody] CategoryDeleteCommand command, [FromQuery] int id, [FromServices] IHandler <CategoryDeleteCommand> handler) { var command = new CategoryDeleteCommand(id); return((GenericCommandResult)await handler.Handle(command)); }
public async Task <IActionResult> DeleteCategory(int id) { var command = new CategoryDeleteCommand(id); var result = await _mediator.Send(command); return(result != null ? (IActionResult)Ok(result) : BadRequest(string.Format(ModelConstants.PropertyNotFoundFromController, "კატეგორია"))); }
public void DeleteCategory(CategoryDeleteCommand deletedCategory) { SendMessage(deletedCategory.Serialize(), CategoryDeleteQueueKeyName); }
public bool Post(CategoryDeleteCommand command) { repositoryUnitOfWork.Categories.Delete(command.CategoryId); return true; }
public async Task <ActionResult> Delete(CategoryDeleteCommand command) { await MediatorService.ExecuteHandler(command); return(NoContent()); }