コード例 #1
0
        public IActionResult Index(string email)
        {
            try
            {
                email         = Convert.ToString(HttpContext.Request.Query["email"]);
                ViewBag.email = email;
            }
            catch (Exception ex)
            {
                log = new EventLog()
                {
                    EventId = (int)LoggingEvents.USER_LOGIN, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source
                };
                _loggerService.SaveEventLogAsync(log);
            }

            return(View());
        }
コード例 #2
0
 public IActionResult SetLanguage(string culture, string returnUrl)
 {
     try
     {
         SetLanguage(culture);
         return(LocalRedirect(returnUrl));
     }
     catch (Exception ex)
     {
         log = new EventLog()
         {
             EventId = (int)LoggingEvents.SET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source
         };
         _loggerService.SaveEventLogAsync(log);
         return(RedirectToAction("Error", "Error500", new ErrorViewModel()
         {
             Error = ex.Message
         }));
     }
 }
コード例 #3
0
        public IActionResult Index()
        {
            try
            {
                var agent = Request.Headers["User-Agent"];
                Console.WriteLine(agent.ToString());
                ViewBag.Browser = agent.ToString();
                var model = new DonationViewModel()
                {
                    DonationCycles = GetDonationCycles
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                log = new EventLog()
                {
                    EventId = (int)LoggingEvents.GET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source
                };
                _loggerService.SaveEventLogAsync(log);
                return(RedirectToAction("Error", "Error500", new ErrorViewModel()
                {
                    Error = ex.Message
                }));
            }
        }
コード例 #4
0
        public IActionResult Delete(string subscriptionId)
        {
            try
            {
                var subscriptionService = new StripeSubscriptionService(_stripeSettings.Value.SecretKey);
                var result = subscriptionService.Cancel(subscriptionId);

                SetTempMessage(_localizer["You have successfully deleted"] + result.StripePlan.Nickname
                               + _localizer["subscription"]);
                return(RedirectToAction("Index", "Manage"));
            }
            catch (Exception ex)
            {
                log = new EventLog()
                {
                    EventId = (int)LoggingEvents.DELETE_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source
                };
                _loggerService.SaveEventLogAsync(log);
                return(RedirectToAction("Error", "Error500", new ErrorViewModel()
                {
                    Error = ex.Message
                }));
            }
        }
コード例 #5
0
        public async Task <IActionResult> Payment(int id)
        {
            var user = await GetCurrentUserAsync();

            try
            {
                var donation = _donationService.GetById(id);
                var detail   = (DonationViewModel)donation;
                List <CountryViewModel> countryList = GetCountryList();

                // Check for existing customer
                // edit = 1 means user wants to edit the credit card information
                if (!string.IsNullOrEmpty(user.StripeCustomerId))
                {
                    try
                    {
                        var            CustomerService   = new StripeCustomerService(_stripeSettings.Value.SecretKey);
                        StripeCustomer objStripeCustomer = CustomerService.Get(user.StripeCustomerId);
                        StripeCard     objStripeCard     = null;

                        if (objStripeCustomer.Sources != null && objStripeCustomer.Sources.TotalCount > 0 && objStripeCustomer.Sources.Data.Any())
                        {
                            objStripeCard = objStripeCustomer.Sources.Data.FirstOrDefault().Card;
                        }

                        if (objStripeCard != null && !string.IsNullOrEmpty(objStripeCard.Id))
                        {
                            CustomerRePaymentViewModel customerRePaymentViewModel = CustomerRepaymentModelData(user, donation, detail, countryList, objStripeCustomer, objStripeCard);
                            return(View("RePayment", customerRePaymentViewModel));
                        }
                    }
                    catch (StripeException ex)
                    {
                        log = new EventLog()
                        {
                            EventId = (int)LoggingEvents.GET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, EmailId = user.Email
                        };
                        _loggerService.SaveEventLogAsync(log);
                        ModelState.AddModelError("CustomerNotFound", ex.Message);
                    }
                }

                CustomerPaymentViewModel customerPaymentViewModel = GetCustomerPaymentModel(user, donation, detail, countryList);
                return(View("Payment", customerPaymentViewModel));
            }
            catch (Exception ex)
            {
                log = new EventLog()
                {
                    EventId = (int)LoggingEvents.GET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, EmailId = user.Email
                };
                _loggerService.SaveEventLogAsync(log);
                return(RedirectToAction("Error", "Error500", new ErrorViewModel()
                {
                    Error = ex.Message
                }));
            }
        }
コード例 #6
0
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            try
            {
                ViewData["ReturnUrl"] = returnUrl;
                if (ModelState.IsValid)
                {
                    // This doesn't count login failures towards account lockout
                    // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                    var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : true);

                    if (result.Succeeded)
                    {
                        return(RedirectToLocal(returnUrl));
                    }

                    if (result.RequiresTwoFactor)
                    {
                        return(RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));
                    }

                    if (result.IsLockedOut)
                    {
                        return(View("Lockout"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, _localizer["Invalid login attempt."]);
                        return(View(model));
                    }
                }
            }
            catch (Exception ex)
            {
                log = new EventLog()
                {
                    EventId = (int)LoggingEvents.USER_LOGIN, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source
                };
                _loggerService.SaveEventLogAsync(log);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }