Skip to content

Commit

Permalink
Add [EmailAddress] attribute (#876)
Browse files Browse the repository at this point in the history
* Add [EmailAddress] attribute

* Validate model state
  • Loading branch information
vanillajonathan authored and thinkingserious committed Jul 4, 2019
1 parent 56da7a9 commit 2310b6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public ActionResult Send()
[HttpPost]
public ActionResult Send(EmailContract emailContract)
{
if (!ModelState.IsValid)
{
return View(model);
}

try
{
var response= _sendGridEmailService.Send(emailContract);
Expand All @@ -37,4 +42,4 @@ public ActionResult Send(EmailContract emailContract)
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ public class EmailContract
{
[Required]
[Display(Name = "From Email Address")]
[EmailAddress]
public string FromEmailAddress { get; set; }

public string Alias { get; set; }

[Required]
[Display(Name = "To Email Address")]
[EmailAddress]
public string ToEmailAddress { get; set; }

[Display(Name = "Cc Email Address")]
[EmailAddress]
public string CcEmailAddress { get; set; }

[Display(Name = "Bcc Email Address")]
[EmailAddress]
public string BccEmailAddress { get; set; }

[Required]
[Display(Name = "Subject")]
public string Subject { get; set; }

[Required]
[Display(Name = "Body")]
public string Body { get; set; }
}
}
}

0 comments on commit 2310b6e

Please sign in to comment.