Beispiel #1
0
        // GET: Income/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var income = await _repository.Get((int)id);

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

            return(View(income));
        }
Beispiel #2
0
        public async Task <ActionResult <Income> > GetIncome(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());
            }

            return(Ok(income));
        }
Beispiel #3
0
        public void DeleteIncome(Int32 userId, Int32 incomeId)
        {
            var income = _incomeRepository.Get(incomeId);

            if (income != null || income.UserId == userId)
            {
                _incomeRepository.Delete(income);
            }
        }
Beispiel #4
0
        public async Task UpdateIncome(string userId, IncomeModel income)
        {
            try
            {
                UserModel user = await _userRepository.Get(userId);

                IncomeModel oldIncome = await _incomeRepository.Get(income._id);

                if (income.Amount != oldIncome.Amount)
                {
                    user.Wallets.Add(await UpdateWalletForUpdatedIncome(user, income, oldIncome));
                }


                await _incomeRepository.Update(income._id, income);

                await _userRepository.Update(userId, user);
            }
            catch (Exception e)
            {
                throw new Exception();
            }
        }
Beispiel #5
0
 public IncomeQuestionnaire Get(int id)
 {
     return(_repository.Get(id));
 }
Beispiel #6
0
 public List <Income> Get()
 {
     return(incomeRepository.Get());
 }
Beispiel #7
0
 public Income Get(int id)
 {
     return(_incomeRepository.Get(id));
 }