public Task Delete(Guid id)
        {
            var command = new DeleteProductCategoryCommand(id);

            _commandBus.ExecuteAsync(command).Wait();
            return(Task.CompletedTask);
        }
        public Task ExecuteAsync(DeleteProductCategoryCommand command)
        {
            var productCategoryDomain = new ProductCategoryDomain(_writeService);

            productCategoryDomain.Delete(command.Id);

            _domainService.ApplyChanges(productCategoryDomain);
            return(Task.CompletedTask);
        }
Esempio n. 3
0
        public JsonResult DeleteCategory(DeleteProductCategoryCommand command)
        {
            if (ModelState.IsValid)
            {
                return(Json(ModelState.Values));
            }
            var result = _commandBus.Send(command);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonResult DeleteCategory(DeleteProductCategoryCommand command)
        {
            if (ModelState.IsValid)
            {
                return(Json(ModelState.Values));
            }
            var result = _commandBus.Send(command);

            return(JsonMessage(result));
        }
Esempio n. 5
0
        public async Task <IActionResult> Delete(Guid id)
        {
            try
            {
                var deleteProductCategoryCommand = new DeleteProductCategoryCommand {
                    PoductCategoryId = id
                };
                await _deleteProductCategoryCommand.Handle(deleteProductCategoryCommand, CancellationToken.None);

                return(Ok(new ApiResponse(200)));
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex, $"Error on Delete Product Category [{id}]");
                return(BadRequest(new ApiBadRequestResponse(500, "Something Wrong")));
            }
        }
        public async Task DeleteProductCategoryCommandHandle_DeletingCategory()
        {
            //Arrange
            AllMarktContextIM.Shops.Add(new AllMarkt.Entities.Shop
            {
                Address           = "dddd",
                Comments          = null,
                CUI               = "ddd",
                IBAN              = "dffddfdfd",
                Orders            = null,
                PhoneNumber       = "0123654789",
                ProductCategories = null,
                ShopCategoryLink  = null,
                SocialCapital     = 3
            });
            AllMarktContextIM.SaveChanges();
            var shop = AllMarktContextIM.Shops.First();

            AllMarktContextIM.ProductCategories.Add(new AllMarkt.Entities.ProductCategory
            {
                Name        = "TestName",
                Description = "TestDescription",
                Shop        = shop,
                Products    = null
            });
            AllMarktContextIM.SaveChanges();
            var existentProductCategory = AllMarktContextIM.ProductCategories.First();
            var deletedProductCategory  = new DeleteProductCategoryCommand {
                Id = existentProductCategory.Id
            };

            //Act
            await _deleteProductCategoryHandler.Handle(deletedProductCategory, CancellationToken.None);

            //Assert
            AllMarktContextIM.ProductCategories
            .Should()
            .NotContain(productCategory => productCategory.Id == deletedProductCategory.Id);
        }
Esempio n. 7
0
        public async Task <IActionResult> Delete([FromQuery] DeleteProductCategoryCommand command)
        {
            await Mediator.Send(command);

            return(Ok());
        }