public async Task <IActionResult> RequestUndo(int id, string description)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            var transaction = await _transactionRepository.GetAsync(id);

            transaction.Status = TransactionStatus.PendingCancellation;
            await _transactionRepository.UpdateAsync(transaction);

            _logger.Log("ClientTransactionController", $"User {currentUser.UserName} submitted transaction {id} to be undone!");

            return(RedirectToAction("Details", new { id }));
        }
        public async Task <IActionResult> Login(LoginModel model)
        {
            var(status, message) = await _userService.LoginWithPasswordAsync(model.Username, model.Password);

            if (!status)
            {
                ViewBag.Notification = new NotificationModel(message).asError();
                return(View("Index"));
            }

            _logger.Log("IdentityController", "User " + model.Username + " logged in");
            return(RedirectToAction("Index", "Overview"));
        }
Example #3
0
        public async Task <IActionResult> Verify(int id)
        {
            if (!User.IsInRole(Role.Admin))
            {
                return(RedirectToAction("Details", new { id }));
            }

            var user = await _userRepository.GetAsync(id);

            user.Status = UserStatus.Active;

            await _userRepository.UpdateAsync(user);

            _logger.Log("UserManagementController", $"Admin {HttpContext.User.Identity.Name} verified account {user.UserName}");

            return(RedirectToAction("Details", new { id }));
        }
Example #4
0
        public async Task <IActionResult> SaveEdit(UserModel model)
        {
            var user = await _userRepository.GetAsync(User.Id());

            user.Firstname   = model.Firstname;
            user.Lastname    = model.Lastname;
            user.UserName    = model.Username;
            user.PhoneNumber = model.Phone;
            user.Address     = model.Address;
            user.Email       = model.Email;

            await _userRepository.UpdateAsync(user);

            _logger.Log("UserController", $"User {user.UserName} changed his contact information!");

            return(RedirectToAction("Index"));
        }
Example #5
0
        public async Task <IActionResult> Undo(int id)
        {
            if (!User.IsInRole(Role.Admin))
            {
                return(RedirectToAction("Details", new { id }));
            }

            var transaction = await _transactionRepository.GetAsync(id);

            transaction.Status = TransactionStatus.Cancelled;

            await _transactionRepository.UpdateAsync(transaction);

            var account = await _accountRepository.GetAsync(transaction.RecipientAccountId);

            account.Balance -= transaction.Amount;

            await _accountRepository.UpdateAsync(account);

            _logger.Log("TransactionsOverviewController", $"Transaction {transaction.Id} was undone by {HttpContext.User.Identity.Name}");

            return(RedirectToAction("Index"));
        }