Exemplo n.º 1
0
        public async Task <ActionResult> ReprocessNotVerifiedTransaction(UpdateNzdtTransactionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("UpdateErroredTransactionModal", model));
            }

            var result = await NzdtWriter.ReprocessNotVerifiedTransaction(User.Identity.GetUserId(), model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(View("UpdateErroredTransactionModal", model));
            }

            return(CloseModalSuccess(result.Message));
        }
Exemplo n.º 2
0
        public async Task <IWriterResult> AddUserToTransaction(string adminUserId, UpdateNzdtTransactionModel model)
        {
            int transactionId;

            using (var context = ExchangeDataContextFactory.CreateContext())
            {
                var transaction = await context.NzdtTransaction.FirstOrDefaultNoLockAsync(x => x.Id == model.TransactionId).ConfigureAwait(false);

                if (transaction == null)
                {
                    return(new WriterResult(false, "Transaction not Found"));
                }
                else if (transaction.TransactionStatus != Enums.NzdtTransactionStatus.ErrorUserNotFound)
                {
                    return(new WriterResult(false, "Transaction not in ErrorUserNotFound Status"));
                }

                var user = await context.Users.FirstOrDefaultNoLockAsync(x => x.UserName == model.UserName).ConfigureAwait(false);

                if (user == null)
                {
                    return(new WriterResult(false, "User not Found"));
                }
                else if (user.VerificationLevel != Enums.VerificationLevel.Level2 && user.VerificationLevel != Enums.VerificationLevel.Level3)
                {
                    return(new WriterResult(false, "User Verification level is not Level2 or Level3"));
                }

                transactionId = transaction.Id;

                transaction.User = user;
                transaction.TransactionStatus = Enums.NzdtTransactionStatus.ReadyForProcessing;

                await context.SaveChangesAsync().ConfigureAwait(false);
            }

            using (var context = HubDataContextFactory.CreateContext())
            {
                var logMessage = $"[NZDT Import] Added User To Transaction with Id {transactionId}";

                context.LogActivity(adminUserId, logMessage);
                await context.SaveChangesAsync().ConfigureAwait(false);
            }

            return(new WriterResult(true, "User Added to Transaction"));
        }