Пример #1
0
        public void LoggedIn(IUser user)
        {
            try
            {
                var fidelitySettings = _orchardServices.WorkContext.CurrentSite.As <FidelitySiteSettingsPart>();

                if (!string.IsNullOrWhiteSpace(fidelitySettings.DeveloperKey) && // Verifico che l'utente abbia già compilato le impostazioni della fidelity
                    (fidelitySettings.RegisterOnLogin == LoyalzooRegistrationEnum.Always ||
                     (fidelitySettings.RegisterOnLogin == LoyalzooRegistrationEnum.External && _controllerContextAccessor.Context.Controller.GetType().FullName != "Orchard.Users.Controllers.AccountController")))
                {
                    LoyalzooUserPart loyalzooUserData = user.As <LoyalzooUserPart>();

                    if (string.IsNullOrWhiteSpace(loyalzooUserData.LoyalzooUsername) && string.IsNullOrWhiteSpace(loyalzooUserData.LoyalzooPassword) && string.IsNullOrWhiteSpace(loyalzooUserData.CustomerSessionId))
                    {
                        APIResult accountCreationResult = _fidelityService.CreateLoyalzooAccountFromCookie();

                        if (accountCreationResult.success == true)
                        {
                            _controllerContextAccessor.Context.Controller.TempData.Add("LoyalzooRegistrationSuccess", true);
                        }
                        else
                        {
                            _controllerContextAccessor.Context.Controller.TempData.Add("LoyalzooRegistrationSuccess", false);
                        }
                    }
                }
            }
            catch
            { }
        }
 public JsonResult LoyalzooRegistration()
 {
     try
     {
         return(Json(_fidelityService.CreateLoyalzooAccountFromCookie(), JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new APIResult {
             success = false, data = null, message = e.Message
         }, JsonRequestBehavior.AllowGet));
     }
 }