コード例 #1
0
ファイル: ContactController.cs プロジェクト: mnatte/MND
        //
        // GET: /Mail/
        public ActionResult Form([DefaultValue(false)] bool cv)
        {
            var model = new ContactFormData { IsCvRequest = cv };
            var useCaseFillModelContext = new ContactFormPrefillContext(model);
            useCaseFillModelContext.Execute();

            return View("Contact", model);
        }
コード例 #2
0
ファイル: ContactController.cs プロジェクト: mnatte/MND
        // url is domainname/mail/send
        // ModelBinding is underlying here for getting the ContractFormData as a parameter
        public ActionResult Send(ContactFormData model)
        {
            if (ModelState.IsValid)
            {
                var smtpServer = string.IsNullOrEmpty(ConfigurationManager.AppSettings["smtpServer"]) ? "smtp.zonnet.nl" : ConfigurationManager.AppSettings["smtpServer"];
                var usernameSmtp = ConfigurationManager.AppSettings["usernameSmtp"];
                var passwordSmtp = ConfigurationManager.AppSettings["passwordSmtp"];

                var smtpClient = string.IsNullOrEmpty(usernameSmtp) ? new Emailer(smtpServer) : new Emailer(smtpServer, usernameSmtp, passwordSmtp, true);

                var resultModel = new MailResultModel { ResultMessage = string.Empty, Succeeded = true };
                var useCaseContext = new ContactFormSubmitContext(model, new Emailer(smtpServer), resultModel);

                useCaseContext.Execute();

                return View("ContactMailSent", resultModel);
            }
            return View("Contact", model);
        }