public void Delete(int id)
        {
            var expense = _context.Expenses.FirstOrDefault(e => e.ExpenseId == id);

            _context.Remove(expense);
            _context.SaveChanges();
        }
Example #2
0
        public IActionResult Delete(int id)
        {
            var spentItem = _context.DailyExpenses.Find(id);

            if (spentItem == null)
            {
                return(NotFound());
            }
            _context.Remove(spentItem);
            Save();
            return(NoContent());
        }
Example #3
0
        public IActionResult Delete(int id)
        {
            var spentItem = _context.DailyExpenses.Find(id);

            if (spentItem == null)
            {
                //UnComment this for non Serilog Sink to Database
                //_logger.Information($"Daily Expense for {id} does not exists!!");
                _logger.LogInformation($"Daily Expense for {id} does not exists!!");
                return(NotFound());
            }
            _context.Remove(spentItem);
            Save();
            return(NoContent());
        }