Ejemplo n.º 1
0
        public async Task AddAsync(Transaction newTransaction)
        {
            var kid = await _kidRepository.GetKidAsync(newTransaction.KidId);

            newTransaction.Kid = kid;

            kid.Transactions.Add(newTransaction);

            _context.Add(newTransaction);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> CreateTransaction([FromBody] SaveTransactionResource newTransaction)
        {
            var transactionInDb = newTransaction.ToData();

            transactionInDb.UserName  = User.Identity.Name;
            transactionInDb.TimeStamp = DateTime.Now;

            await _transactionRepository.AddAsync(transactionInDb);

            await _unitOfWork.CompleteAsync();

            return(Ok(KidResource.FromData(await _kidRepository.GetKidAsync(newTransaction.KidId, includeRelated: true), includeRelated: true)));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> GetKid(int id)
        {
            var kidInDb = await _kidRepository.GetKidAsync(id, includeRelated : true);

            if (kidInDb == null)
            {
                return(NotFound());
            }

            return(Ok(KidResource.FromData(kidInDb, includeRelated: true)));
        }