public async Task DeleteCategory(int id) { var categoryModel = await context.Category.Where(c => c.id == id).FirstOrDefaultAsync(); if (categoryModel == null) { throw new Exception("Nie ma kategorii o tym ID"); } context.Remove(categoryModel); await context.SaveChangesAsync(); }
public async Task DeleteTransaction(int id) { var transaction = await context.Transaction.Where(t => t.id == id).FirstOrDefaultAsync(); if (transaction == null) { throw new Exception("Brak transakcji o tym ID"); } context.Remove(transaction); await context.SaveChangesAsync(); }