public async Task <ActionResult> Delete(int productId)
        {
            _logger.LogInformation($"Products/{productId} /DELETE");

            using var db = new EvtContext();
            var product = await db.Set <Product>().FindAsync(productId);

            if (product == null)
            {
                return(NotFound());
            }

            db.Remove(product);
            await db.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <ActionResult> Delete(int customerId)
        {
            _logger.LogInformation($"Customers/{customerId} /DELETE");

            using var db = new EvtContext();
            var customer = await db.Set <Customer>().FindAsync(customerId);

            if (customer == null)
            {
                return(NotFound());
            }

            db.Remove(customer);
            await db.SaveChangesAsync();

            return(NoContent());
        }
Пример #3
0
        public async Task <ActionResult> Delete(int orderId)
        {
            _logger.LogInformation($"Orders/{orderId} /DELETE");

            using var db = new EvtContext();
            var orders = await db.Set <Order>().FindAsync(orderId);

            if (orders == null)
            {
                return(NotFound());
            }

            db.Remove(orders);
            await db.SaveChangesAsync();

            return(NoContent());
        }