Exemplo n.º 1
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"));
            }
        }
Exemplo n.º 2
0
        public ViewResult RequestValuation(int id)
        {
            var journal         = this.journalRepository.Find(id);
            var resourceManager = new ResourceManager(typeof(RequestValuation));
            var model           = new RequestValuationViewModel
            {
                JournalId    = id,
                JournalTitle = journal.Title,
                JournalISSN  = journal.ISSN,
                EmailBody    = resourceManager.GetString("Body")
                               .Replace("<<JournalTitle>>", journal.Title),
                EmailSubject = resourceManager.GetString("Subject")
                               .Replace("<<JournalTitle>>", journal.Title)
                               .Replace("<<JournalISSN>>", journal.ISSN),
            };

            var currentUser = this.UserProfileRepository.Find(this.Authentication.CurrentUserId);

            if (currentUser != null)
            {
                model.EmailFrom = currentUser.Email;
            }

            return(this.View(model));
        }
Exemplo n.º 3
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"));
            }
        }
Exemplo n.º 4
0
        public ActionResult RegisterSuccessWithLink(string addLink)
        {
            var model = new RequestValuationViewModel {
                JournalId = Convert.ToInt32(addLink.Split('/').Last())
            };

            model.JournalTitle = this.journalRepository.Find(model.JournalId).Title;

            return(this.View(model));
        }
Exemplo n.º 5
0
 string FillEmailUrl(RequestValuationViewModel model)
 {
     return(model.IsKnownEmailAddress
         ? Url.Action("Login", "Account", new { ReturnUrl = Url.Action("ValuationScoreCard", new { id = model.JournalId }), loginAddress = model.EmailTo }, Request.Url?.Scheme)
         : Url.Action("Register", "Account", new { loginAddress = model.EmailTo, addLink = Url.Action("ValuationScoreCard", new { id = model.JournalId }) }, Request.Url?.Scheme));
 }