コード例 #1
0
        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));
        }
コード例 #2
0
        public IActionResult Delete([FromBody] CategoryDeleteDto categoryDeleteDto)
        {
            CategoryDeleteCommand categoryDeleteCommand = MapService.Map(categoryDeleteDto);
            Result result = _messages.Dispatch(categoryDeleteCommand);

            return(FromResult(result));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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, "კატეგორია")));
        }
コード例 #5
0
 public void DeleteCategory(CategoryDeleteCommand deletedCategory)
 {
     SendMessage(deletedCategory.Serialize(), CategoryDeleteQueueKeyName);
 }
コード例 #6
0
        public bool Post(CategoryDeleteCommand command)
        {
            repositoryUnitOfWork.Categories.Delete(command.CategoryId);

            return true;
        }
コード例 #7
0
        public async Task <ActionResult> Delete(CategoryDeleteCommand command)
        {
            await MediatorService.ExecuteHandler(command);

            return(NoContent());
        }