示例#1
0
        public ActionResult UnSubscribe(UnsubscribeViewModel model)
        {
            string recaptchaprivatekey = BgResources.Recaptcha_PrivateKeyHttp;
            try
            {
                if (!ReCaptcha.Validate(privateKey: recaptchaprivatekey))
                {
                    ModelState.AddModelError("recaptcha", Resources.AppMessages.Error_Recaptcha);
                }
            }
            catch (Exception)
            {

                ModelState.AddModelError("recaptcha", Resources.AppMessages.Error_Recaptcha_Key);
            }
            if (ModelState.IsValid)
            {
                try
                {
                    SubscriptionServices.Unsubscribe(model.Email);
                }
                catch (ApplicationValidationErrorsException ex)
                {
                    foreach (string str in ex.ValidationErrors)
                    {
                        ModelState.AddModelError("", str);
                    }
                }
            }
            return View();
        }