public IActionResult UpdateTransactionDetails(string userId, string amount, string UserName, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string trasactionId, string paymentId, Domain.Socioboard.Enum.SBAccountType accType, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media)
        {
            try
            {
                var dbr       = new DatabaseRepository(_logger, _appEnv);
                var inMemUser = _redisCache.Get <User>(UserName);

                if (inMemUser != null)
                {
                    inMemUser.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.Processing;
                    inMemUser.AccountType   = accType;
                    inMemUser.ExpiryDate    = DateTime.UtcNow.AddDays(1);
                    inMemUser.TrailStatus   = UserTrailStatus.active;
                    dbr.Update(inMemUser);
                }
                else
                {
                    var user = dbr.FindFirstMatch <User>(t => t.Id == Convert.ToInt64(userId));
                    if (user != null)
                    {
                        user.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.Processing;
                        user.AccountType   = accType;
                        user.ExpiryDate    = DateTime.UtcNow.AddDays(1);
                        user.TrailStatus   = UserTrailStatus.active;
                        dbr.Update(user);
                    }
                }
                var isSaved = Repositories.PaymentTransactionRepository.AddPaymentTransaction(Convert.ToInt64(userId), amount, email, PaymentType, paymentId, trasactionId, subscr_date, payer_email, Payername, "Processing", item_name, media, dbr);
                if (isSaved == 1)
                {
                    return(Ok("processing"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }
            return(Ok());
        }
        public IActionResult UpgradeAccount(string userId, string amount, string UserName, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string trasactionId, string paymentId, Domain.Socioboard.Enum.SBAccountType accType, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media)
        {
            var dbr = new DatabaseRepository(_logger, _appEnv);

            try
            {
                var path = _appEnv.WebRootPath + "\\views\\mailtemplates\\invoice.html";
                var html = System.IO.File.ReadAllText(path);
                html = html.Replace("[paymentId]", paymentId);
                html = html.Replace("[subscr_date]", subscr_date.ToString());
                html = html.Replace("[payer_email]", payer_email);
                html = html.Replace("[Payername]", Payername);
                html = html.Replace("[payment_status]", payment_status);
                html = html.Replace("[item_name]", item_name);
                html = html.Replace("[amount]", amount + "$");
                html = html.Replace("[media]", media);
                _emailSender.SendMailSendGrid(_appSettings.frommail, "", payer_email, "", "", "Socioboard Payment Invoice", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword);
            }
            catch (Exception)
            {
            }
            try
            {
                var inMemUser = _redisCache.Get <User>(UserName);

                if (inMemUser != null)
                {
                    inMemUser.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                    inMemUser.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                    inMemUser.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                    inMemUser.Id          = Convert.ToInt64(userId);
                    inMemUser.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                    inMemUser.AccountType = accType;
                    dbr.Update(inMemUser);
                }
                else
                {
                    var _user = dbr.FindFirstMatch <User>(t => t.Id == Convert.ToInt64(userId));
                    if (_user != null)
                    {
                        _user.PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                        _user.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                        _user.ExpiryDate          = DateTime.UtcNow.AddDays(30);
                        _user.Id          = Convert.ToInt64(userId);
                        _user.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active;
                        _user.AccountType = accType;
                        dbr.Update(_user);
                    }
                }
                int isaved = Repositories.PaymentTransactionRepository.AddPaymentTransaction(Convert.ToInt64(userId), amount, email, PaymentType, paymentId, trasactionId, subscr_date, payer_email, Payername, payment_status, item_name, media, dbr);
                if (isaved == 1)
                {
                    return(Ok("payment done"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }
            return(Ok());
        }