예제 #1
0
        public async Task <IActionResult> Index([Bind("CustomerID,LastAmount,Balance,DepositID")] Deposit deposit)
        {
            var userID = _userManager.GetUserId(User);

            if (ModelState.IsValid)
            {
                var status = 1;
                deposit.CustomerID = userID;
                if (await _depositRepository.IsIDExists(userID))
                {
                    status = 2;
                    await _depositRepository.Update(deposit);
                }
                else
                {
                    await _depositRepository.Add(deposit);
                }
                return(RedirectToAction(nameof(Index), new { id = 0, status, customerID = "" }));
            }
            ViewData["DepositList"] = await _depositRepository.FindAll(userID);

            return(View(deposit));
        }