public void Delete(String ExpenseName) { if (ModelState.IsValid) { ExpenseRepository.Delete(ExpenseName); } }
public async Task <IActionResult> Delete(long id) { var provider = await expenseRepo.WithId(id); await expenseRepo.Delete(provider); return(new OkObjectResult(provider)); }
//delete data public bool Delete(int id) { var isDelete = false; isDelete = _expenseRepository.Delete(id); if (isDelete) { return(true); } return(isDelete); }
public void Can_Delete_Saved_Expense_From_DataBase() { using (var repo = new ExpenseRepository(_context)) { _context.Staffs.Add(sampleManager); _context.SaveChanges(); var staff = _context.Staffs.Single(); repo.Create(new Expense("E1", 2000, staff.Id)); repo.Create(new Expense("E2", 2000, staff.Id)); Assert.IsTrue(_context.Expenses.Count() == 2); Expense expense = _context.Expenses.First(); repo.Delete(expense.Id); Assert.AreEqual(1, _context.Expenses.Count()); } }
public bool DeleteExpense(Expense entity, bool save = true) { try { _expenseRepository.Delete(entity); if (save) { _expenseRepository.Save(); } return(true); } catch (SqlException e) { Logger.Instance.Error(e); return(false); } catch (Exception ex) { Logger.Instance.Error(ex); return(false); } }
public async Task <ActionResult> DeleteExpenseAsync(int id) { var expense = await expenseRepository.GetByIdAsync(id, exp => exp.Budget); if (expense == null) { return(NotFound($"No Expense with Id {id} found.")); } if (!IsUserAuthorizedForResource(expense.Budget)) { return(Unauthorized("You can only access your own expenses.")); } expenseRepository.Delete(expense); var saveResults = await expenseRepository.SaveAllAsync(); if (!saveResults) { return(BadRequest("Failed to delete the expense.")); } return(NoContent()); }
public Expense Delete([FromBody] Expense expense) { _repository.Delete(expense); return(expense); }
public void ExpenseDelete(Expense expense) { ExpenseRepository.Delete(expense); }
public ActionResult delete(int id) { _rep.Delete(id); return(RedirectToAction("")); }
public ActionResult DeleteConfirmed(int id) { expenseRepository.Delete(id); expenseRepository.SaveChanges(); return(RedirectToAction("Index")); }