public void DeleteById() { if (this.IncomeId <= 0) { throw new ArgumentException("Income id should be greater than zero"); } _incomeRepository.Delete(this.IncomeId); _incomeMongoRepository.RemoveDocumentByIncomeId(this.IncomeId); }
public void DeleteIncome(Int32 userId, Int32 incomeId) { var income = _incomeRepository.Get(incomeId); if (income != null || income.UserId == userId) { _incomeRepository.Delete(income); } }
public ActionResult Delete(int incomeID) { Income deletedIncome = repository.Delete(incomeID); if (deletedIncome != null) { TempData["message"] = string.Format("Usunięto {0} z dnia {1}", deletedIncome.Description, deletedIncome.Date.ToString("d")); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Delete(int id) { try { return(Ok(await _repo.Delete(id))); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public void DeleteIncome(int id) { var income = _incomeRepository.GetById(id); var account = _bankAccountRepository.GetById(income.AccountId); MovementHelpers.Debit(_historicMovementRepository, income.Cost, account.Id, ObjectType.Account, account.CurrentBalance); account.CurrentBalance -= income.Cost; _bankAccountRepository.Update(account); _incomeRepository.Delete(income); }
public ActionResult Delete(int id) { // Validations var income = _repoIncome.WithKey(id); if (income == null) { return(NotFound()); } // Logic _repoIncome.Delete(income); Storage.Save(); // Response return(RedirectToAction("Index")); }
public async Task <RecordDetailResponseModel> DeleteIncome(int id) { var record = await _incomeRepository.GetById(id); if (record == null) { return(null); } var response = new RecordDetailResponseModel { UserId = record.UserId, Amount = record.Amount, Description = record.Description, Date = record.IncomeDate, Remarks = record.Remarks, }; await _incomeRepository.Delete(record); return(response); }
public async Task <IActionResult> Delete(int id) { try { var oldIncome = _incomeRepository.GetIncomes(id); if (oldIncome == null) { return(NotFound($"Could not find a Income with an ID of: {id}")); } _incomeRepository.Delete(oldIncome); if (await _incomeRepository.SaveAllAsync()) { return(Ok()); } } catch (Exception ex) { } return(BadRequest("Could not delete Income")); }
public async Task <ActionResult <Income> > DeleteIncome(int id) { var user = await _repository.ValidUser(GetTokenUserId()); if (user == null) { return(NotFound()); } var income = await _repository.Get(id, user.Id); if (income == null) { return(NotFound()); } if (await _repository.Delete(id) == null) { return(BadRequest()); } return(income); }
public void DeleteIncome(int incomeId) { _incomeRepository.Delete(incomeId); }
public async Task <IActionResult> DeleteConfirmed(int id) { await _repository.Delete(id); return(RedirectToAction(nameof(Index))); }
public IActionResult Delete(int incomeId) { _repository.Delete(incomeId); return(RedirectToAction(nameof(List))); }