public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, Model.DatabaseRepository dbr)
 {
     try
     {
         Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = new Domain.Socioboard.Models.PaymentTransaction();
         _PaymentTransaction.amount       = amount;
         _PaymentTransaction.email        = email;
         _PaymentTransaction.paymentdate  = DateTime.UtcNow;
         _PaymentTransaction.userid       = userId;
         _PaymentTransaction.PaymentType  = PaymentType;
         _PaymentTransaction.trasactionId = trasactionId;
         _PaymentTransaction.paymentId    = paymentId;
         int isaved = dbr.Add <Domain.Socioboard.Models.PaymentTransaction>(_PaymentTransaction);
         return(isaved);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="amount"></param>
 /// <param name="email"></param>
 /// <param name="PaymentType"></param>
 /// <param name="paymentId"></param>
 /// <param name="trasactionId"></param>
 /// <param name="subscr_date"></param>
 /// <param name="payer_email"></param>
 /// <param name="Payername"></param>
 /// <param name="payment_status"></param>
 /// <param name="item_name"></param>
 /// <param name="media"></param>
 /// <param name="dbr"></param>
 /// <returns></returns>
 public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media, Model.DatabaseRepository dbr)
 {
     try
     {
         var paymentTransaction = new Domain.Socioboard.Models.PaymentTransaction
         {
             amount        = amount,
             email         = email,
             paymentdate   = DateTime.UtcNow,
             userid        = userId,
             PaymentType   = PaymentType,
             trasactionId  = trasactionId,
             paymentId     = paymentId,
             payeremail    = payer_email,
             Payername     = Payername,
             paymentstatus = payment_status,
             itemname      = item_name,
             media         = media,
             subscrdate    = subscr_date
         };
         return(dbr.Add(paymentTransaction));
     }
     catch (Exception)
     {
         return(0);
     }
 }
 public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media, Model.DatabaseRepository dbr)
 {
     try
     {
         Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = new Domain.Socioboard.Models.PaymentTransaction();
         _PaymentTransaction.amount        = amount;
         _PaymentTransaction.email         = email;
         _PaymentTransaction.paymentdate   = DateTime.UtcNow;
         _PaymentTransaction.userid        = userId;
         _PaymentTransaction.PaymentType   = PaymentType;
         _PaymentTransaction.trasactionId  = trasactionId;
         _PaymentTransaction.paymentId     = paymentId;
         _PaymentTransaction.payeremail    = payer_email;
         _PaymentTransaction.Payername     = Payername;
         _PaymentTransaction.paymentstatus = payment_status;
         _PaymentTransaction.itemname      = item_name;
         _PaymentTransaction.media         = media;
         _PaymentTransaction.subscrdate    = subscr_date;
         int isaved = dbr.Add <Domain.Socioboard.Models.PaymentTransaction>(_PaymentTransaction);
         return(isaved);
     }
     catch (Exception)
     {
         return(0);
     }
 }
        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)
        {
            Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            try
            {
                User 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;
                    if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                    }
                    dbr.Update <User>(inMemUser);
                }
                else
                {
                    User _user = dbr.Single <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;
                        if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                        }
                        dbr.Update <User>(_user);
                    }
                }
                int isaved = Repositories.PaymentTransactionRepository.AddPaymentTransaction(Convert.ToInt64(userId), amount, email, PaymentType, paymentId, trasactionId, dbr);
                if (isaved == 1)
                {
                    return(Ok("payment done"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
            }
            return(Ok());
        }
Ejemplo n.º 5
0
        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)
        {
            Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv);
            try
            {
                string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\invoice.html";
                string 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
            {
                User 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;
                    if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                    }
                    else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                    {
                        inMemUser.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                    }
                    dbr.Update <User>(inMemUser);
                }
                else
                {
                    User _user = dbr.Single <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;
                        if (accType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby;
                        }
                        else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard)
                        {
                            _user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard;
                        }
                        dbr.Update <User>(_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());
        }