Пример #1
0
        public static async Task RemoveProductType(ProductTypeId id)
        {
            var connectionString      = ConnectivityService.GetConnectionString("TEMP");
            var context               = new SplurgeStopDbContext(connectionString);
            var repository            = new ProductTypeRepository(context);
            var unitOfWork            = new EfCoreUnitOfWork(context);
            var service               = new ProductTypeService(repository, unitOfWork);
            var productTypeController = new ProductTypeController(service);

            var updateCommand = new Commands.DeleteProductType
            {
                Id = id
            };

            await productTypeController.DeleteProductType(updateCommand);
        }
        public async Task <ActionResult <ProductTypeDeleted> > DeleteProductType(Commands.DeleteProductType request)
        {
            var result = await RequestHandler.HandleCommand(request, service.Handle);

            if (result.GetType() == typeof(OkResult))
            {
                return new ProductTypeDeleted {
                           Id = request.Id
                }
            }
            ;

            else
            {
                return(new BadRequestObjectResult(new { error = "Error occurred during delete attempt." }));
            }
        }