コード例 #1
0
        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))));
        }
コード例 #2
0
        // 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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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()));
        }