Exemplo n.º 1
0
        public async Task Delete(int id)
        {
            var carToDelete = await _inventoryDbContext.Cars.FindAsync(id);

            _inventoryDbContext.Remove(carToDelete);
            await _inventoryDbContext.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public void DeleteAgent(int id)
        {
            var agent = _context.Agents.Find(id);

            _context.Remove(agent);
            _context.SaveChanges();
        }
        public void DeleteManager(int id)
        {
            var manager = _context.Managers.Find(id);

            _context.Remove(manager);
            _context.SaveChanges();
        }
Exemplo n.º 4
0
        public void DeleteEquipment(int id)
        {
            var equipment = _context.Equipments.Find(id);

            _context.Remove(equipment);
            _context.SaveChanges();
        }
        public IActionResult Delete(int Id)
        {
            var ItemToDelete = _context.InventoryItems.Where(i => i.Id == Id).SingleOrDefault();

            if (ItemToDelete != null)
            {
                _context.Remove(ItemToDelete);
                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public string CancelOrder(int OrderId)
        {
            var entityOrder = InventoryDbContext.Orders.SingleOrDefault(order => order.Id == OrderId);

            if (entityOrder == null)
            {
                return(null);
            }

            InventoryDbContext.Remove(entityOrder);
            InventoryDbContext.SaveChanges();

            return($"Order {OrderId} cancelled.");
        }
Exemplo n.º 7
0
        public async Task <bool> DeleteProductAsync(int id)
        {
            var product = await context.Product.FirstOrDefaultAsync(p => p.Id == id);

            context.Remove(product);
            try
            {
                return(await context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (Exception exp)
            {
                logger.LogError($"Error in {nameof(DeleteProductAsync)}: " + exp.Message);
            }
            return(false);
        }
 public IActionResult Delete(int Id)
 {
     _context.Remove(_context.Locations.Where(c => c.Id == Id).Single());
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public void Delete(T entity)
        {
            _context.Remove(entity);

            Save();
        }