render jquery script, update mail model

This commit is contained in:
nlitkowski 2018-12-09 02:20:46 +01:00
parent 2e11f16369
commit 02c2d8b519
2 changed files with 20 additions and 7 deletions

View File

@ -13,18 +13,23 @@ namespace MailSender.Models
{
[Key]
public int Id { get; set; }
//[ForeignKey]
//public int UserId //id usera ktory wyslal maila
[Display(Name = "Subject")]
[Required]
[Required(AllowEmptyStrings = false)]
public string Subject { get; set; }
[EmailAddress]
[Required]
[DataType(DataType.EmailAddress)]
[Required(AllowEmptyStrings = false, ErrorMessage = "You need to type in an e-mail")]
[RegularExpression(".*@.*\\..*", ErrorMessage = "You typed in e-mail in wrong format")]
[Display(Name = "E-Mail to")]
public string EMailTo { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "You need to type in a message to send")]
[DataType(DataType.Text)]
[StringLength(500, ErrorMessage = "Message can be at most 500 characters long")]
[StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)]
public string Content { get; set; }
}
}

View File

@ -4,26 +4,34 @@
}
<h2>Send Mail</h2>
@if(ViewData.ContainsKey("mailErr")){
<h3>Error: @ViewData["mailErr"]</h3>
}
@if (ViewData.ContainsKey("mailErr"))
{
<h3>Error: @ViewData["mailErr"]</h3>
}
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<div class="form-group">
@Html.LabelFor(i => i.Subject, new { @class = "label-form" })
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @class = "form-control", @placeholder = "Subject" } })
@Html.ValidationMessageFor(i => i.Subject)
</div>
<div class="form-group">
@Html.LabelFor(i => i.EMailTo, new { @class = "label-form" })
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @class = "form-control", @placeholder = "To" } })
@Html.ValidationMessageFor(i => i.EMailTo)
</div>
<div class="form-group">
@Html.LabelFor(i => i.Content, new { @class = "label-form" })
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @class = "form-control", @placeholder = "Body" } })
@Html.ValidationMessageFor(i => i.Content)
</div>
<input type="submit" value="Send" />
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}