public async Task <ICommandResult> Handle(CategoryUpdateCommand 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, Description = command.Description }; var _result = await _cudRepository.Update(_entity); //retorna o resultado if (!_result) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result)); } return(new GenericCommandResult(true, HttpStatusCode.OK, _result)); }
public IActionResult Update([FromBody] CategoryUpdateDto categoryUpdateDto) { CategoryUpdateCommand categoryUpdateCommand = MapService.Map(categoryUpdateDto); Result result = _messages.Dispatch(categoryUpdateCommand); return(FromResult(result)); }
public async Task <IActionResult> PutCategory(int id, CategoryRequestCommand userRequest) { var command = new CategoryUpdateCommand(userRequest, id); var result = await _mediator.Send(command); return(result != null ? (IActionResult)Ok(result) : NotFound(string.Format(ModelConstants.PropertyNotFoundFromController, "კატეგორია"))); }
public void UpdateCategory(CategoryUpdateCommand updatedCategory) { SendMessage(updatedCategory.Serialize(), CategoryUpdateQueueKeyName); }
public async Task <GenericCommandResult> UpdateCategory( [FromBody] CategoryUpdateCommand command, [FromServices] IHandler <CategoryUpdateCommand> handler) { return((GenericCommandResult)await handler.Handle(command)); }
public async Task <ActionResult> Update(CategoryUpdateCommand command) { await MediatorService.ExecuteHandler(command); return(NoContent()); }