Exemplo n.º 1
0
        public ActionResult Send(String email, String username, String investigatorName)
        {
            if (email == null || username == null || investigatorName == null)
            {
                return(View(ErrorView));
            }
            var dataModel = new DataModel()
            {
                Email            = email,
                Username         = username,
                InvestigatorName = investigatorName
            };
            // set Action in database
            Guid?guid = null;

            using (var e = new EntityContext())
            {
                guid = ActionData.SetNewAction(new NewActionData()
                {
                    ActionNumber     = ActionNumberEnum.Register,
                    InvestigatorName = investigatorName,
                    Model            = dataModel
                }, e);
                if (guid == null)
                {
                    return(View(ErrorView));
                }
            }
            var emailModel = new EmailModel()
            {
                ActionGuid = guid ?? default(Guid)
            };
            // send mail
            var bodyHtml = RazorExtensions.RazorToHtml(EmailView, emailModel, this.ControllerContext);
            var subject  = "Email Confirmation, Inventor Access Portal";
            var mailSent = SendEmail.Send(subject, bodyHtml, email, true);

            if (!mailSent)
            {
                return(View(ErrorView));
            }
            return(View(SentView));
        }