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))); }
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))); }
public async Task <ActionResult> CreateKid([FromBody] SaveKidResource newKid) { if (!(await _cabinRepository.CabinExistsAsync(newKid.CabinId))) { return(BadRequest()); } var kidInDb = newKid.ToData(); _kidRepository.Add(kidInDb); await _unitOfWork.CompleteAsync(); kidInDb = await _kidRepository.GetKidAsync(kidInDb.Id, includeRelated : true); return(Ok(KidResource.FromData(kidInDb, includeRelated: true))); }
public async Task <ActionResult> GetKids() { return(Ok((await _kidRepository.GetKidsAsync(includeRelated: true)).Select(c => KidResource.FromData(c, includeRelated: true)))); }