public async Task <IActionResult> Hide()
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            currentUser.ShowMinAndGoal   = true;
            _db.Entry(currentUser).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index", "Fund"));
        }
Exemple #2
0
        public async Task <IActionResult> Create(Transaction transaction)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            transaction.User = currentUser;
            if (transaction.Type == "Withdrawal")
            {
                transaction.Amount = -transaction.Amount;
            }
            var currentFund = _db.Funds.FirstOrDefault(x => x.FundId == transaction.FundId);

            currentFund.AdjustTotal(transaction);
            _db.Entry(currentFund).State = EntityState.Modified;
            _db.Transactions.Add(transaction);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IActionResult Edit([Bind("Name", "CategoryId")] CategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                var thisCategory = _db.Categories.FirstOrDefault(categories => categories.CategoryId == model.CategoryId);
                thisCategory.Name             = model.Name;
                _db.Entry(thisCategory).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            {
                return(View());
            }
        }
Exemple #4
0
        public IActionResult Edit([Bind("Name", "FundId", "Minimum", "Goal")] FundViewModel model)
        {
            if (ModelState.IsValid)
            {
                var thisFund = _db.Funds.FirstOrDefault(funds => funds.FundId == model.FundId);
                thisFund.Name             = model.Name;
                _db.Entry(thisFund).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            {
                return(View());
            }
        }