예제 #1
0
        public ActionResult RequestValuation(RequestValuationViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            model.IsKnownEmailAddress = IsKnownEmailAddress(model.EmailTo);
            model.HasKnownEmailDomain = HasKnownEmailDomain(model.EmailTo);

            // NOTE: Requirements have changed. Leo Waaijers requested that e-mail addresses with unknown domains could be invited to fill in a Score Card - Sergi Papaseit (2015-12-10)
            //if (!model.IsKnownEmailAddress && !model.HasKnownEmailDomain)
            //{
            //    ModelState.AddModelError("", "Sorry, the domain name in the email address of the addressee does not match the name of an academic institution known to us. If you want this institution to be included in our list, please enter it’s name and web address in our contact box and we will respond promptly.");

            //    return View(model);
            //}

            var email = model.ToRequestValuationEmail();
            email.Url = FillEmailUrl(model);

            try
            {
                email.Send();

                return this.RedirectToAction("RequestValuationResult", new { success = true });
            }
            catch
            {
                return this.RedirectToAction("RequestValuationResult");
            }
        }
예제 #2
0
        public ActionResult RequestValuation(RequestValuationViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            model.IsKnownEmailAddress = this.IsKnownEmailAddress(model.EmailTo);
            model.HasKnownEmailDomain = this.HasKnownEmailDomain(model.EmailTo);

            if (!model.IsKnownEmailAddress && !model.HasKnownEmailDomain)
            {
                this.ModelState.AddModelError("", "Sorry, the domain name in your email address does not match the name of an academic institution known to us. If you want your institution to be included in our list, please enter it’s name and web address in our contact box and we will respond promptly.");

                return this.View(model);
            }

            var email = model.ToRequestValuationEmail();
            email.Url = model.IsKnownEmailAddress
                ? this.Url.Action("Login", "Account", new { ReturnUrl = this.Url.Action("ValuationScoreCard", new { id = model.JournalId }), loginAddress = model.EmailTo }, this.Request.Url.Scheme)
                : this.Url.Action("Register", "Account", new { loginAddress = model.EmailTo, addLink = this.Url.Action("ValuationScoreCard", new { id = model.JournalId }) }, this.Request.Url.Scheme);

            try
            {
                email.Send();

                return this.RedirectToAction("RequestValuationResult", new { success = true });
            }
            catch
            {
                return this.RedirectToAction("RequestValuationResult");
            }
        }