Exemplo n.º 1
0
 public void Delete(String ExpenseName)
 {
     if (ModelState.IsValid)
     {
         ExpenseRepository.Delete(ExpenseName);
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(long id)
        {
            var provider = await expenseRepo.WithId(id);

            await expenseRepo.Delete(provider);

            return(new OkObjectResult(provider));
        }
Exemplo n.º 3
0
        //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());
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
 public Expense Delete([FromBody] Expense expense)
 {
     _repository.Delete(expense);
     return(expense);
 }
Exemplo n.º 8
0
 public void ExpenseDelete(Expense expense)
 {
     ExpenseRepository.Delete(expense);
 }
Exemplo n.º 9
0
 public ActionResult delete(int id)
 {
     _rep.Delete(id);
     return(RedirectToAction(""));
 }
 public ActionResult DeleteConfirmed(int id)
 {
     expenseRepository.Delete(id);
     expenseRepository.SaveChanges();
     return(RedirectToAction("Index"));
 }