コード例 #1
0
        public async Task <ActionResult <BrandDeleted> > DeleteBrand(Commands.DeleteBrand request)
        {
            var result = await RequestHandler.HandleCommand(request, _service.Handle);

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

            return(new BadRequestObjectResult(new { error = "Error occurred during delete attempt." }));
        }
    }
コード例 #2
0
        public static async Task RemoveBrand(BrandId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new BrandRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new BrandService(repository, unitOfWork);
            var brandController  = new BrandController(service);

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

            await brandController.DeleteBrand(updateCommand);
        }