public async Task <IActionResult> Post(SpendingForAddDTO model) { Spending spending = mapper.Map <Spending>(model); //spending.UserId = 1; await spendingRepository.Add(spending).ConfigureAwait(true); await unitOfWork.CompleteAsync().ConfigureAwait(true); return(Ok(mapper.Map <SpendingForGetDTO>(await spendingRepository.Get(spending.Id).ConfigureAwait(true)))); }
// GET: Spending/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var spending = await _repository.Get((int)id); if (spending == null) { return(NotFound()); } return(View(spending)); }
public async Task <ActionResult <Spending> > GetSpending(int id) { var user = await _repository.ValidUser(GetTokenUserId()); if (user == null) { return(NotFound()); } var spending = await _repository.Get(id, user.Id); if (spending == null) { return(NotFound()); } return(Ok(spending)); }
public ActionResult <SpendingViewModel> Get(long id) { Domain.Entity.Spending spending = _spendingRepository.Get(id); if (spending == null) { return(NotFound("Spending not found")); } return(Ok(spending.ToViewModel())); }