public Task Post(Guid id, [FromBody] string name)
        {
            var command = new UpdateProductCategoryCommand(id, name);

            _commandBus.ExecuteAsync(command).Wait();
            return(Task.CompletedTask);
        }
 public async Task <IActionResult> Put(int id, UpdateProductCategoryCommand command)
 {
     if (id != command.Id)
     {
         return(BadRequest());
     }
     return(Ok(await _mediator.Send(command)));
 }
 public bool UpdateProductCategory(UpdateProductCategoryCommand updateProductCategoryCommand)
 {
     using (var db = new SqlConnection(_connectionString))
     {
         var sql = @"update [dbo].[ProductCategory]
                     set [Name] = @Name
                     where [Id] = @Id";
         return(db.Execute(sql, updateProductCategoryCommand) == 1);
     }
 }
Ejemplo n.º 4
0
        public async Task OnGetAsync()
        {
            var detail = await _productCategoryQuery.GetProductCategoryDetailAsync(Id);

            Command = new UpdateProductCategoryCommand
            {
                Id          = detail.Id,
                Description = detail.Description,
                Name        = detail.Name
            };
        }
        public Task ExecuteAsync(UpdateProductCategoryCommand command)
        {
            var productCategoryDomain = new ProductCategoryDomain(_writeService);

            productCategoryDomain.Update(new ProductCategoryDto
            {
                Id   = command.Id,
                Name = command.Name
            });

            _domainService.ApplyChanges(productCategoryDomain);
            return(Task.CompletedTask);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Put([FromBody] UpdateProductCategoryCommand request)
        {
            try
            {
                await _updateProductCategoryCommand.Handle(request, CancellationToken.None);

                return(Ok(new ApiResponse(200)));
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex, $"Error on Insert ProductCategory");
                return(BadRequest(new ApiBadRequestResponse(500, "Something Wrong")));
            }
        }
Ejemplo n.º 7
0
 public bool UpdateProductCategory(UpdateProductCategoryCommand updateProductCategoryCommand, int productCategoryId)
 {
     updateProductCategoryCommand.Id = productCategoryId;
     return(_repo.UpdateProductCategory(updateProductCategoryCommand));
 }
Ejemplo n.º 8
0
        public async Task <ActionResult <ProductCategoryDto> > UpdateProductCategory(UpdateProductCategoryCommand request)
        {
            var result = await Mediator.Send(request);

            return(GetResponse(result));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Put([FromBody] UpdateProductCategoryCommand command)
        {
            var result = await Mediator.Send(command);

            return(Ok(new { result }));
        }