关于MVC中的验证问题
我的Model不是写在MVC自带的的Models中。我在添加验证里该怎么验证?
我想在MVC自带的的Models中再写一个一样的Model,验证后再转成别的命名空间中的Model再进行添加操作,可是不知道该怎么转,或者哪位高手有别的更好办法希望指导一下。万分感谢!
别的命名空间中的类:
namespace MkMis.Safety.Domain.Model
{
/// <summary>
/// 通知通告类
/// </summary>
public class Notice : AggregateRoot
{
public string Title { get; set; }
public string Content { get; set; }
public string publisher { get; set; }
public DateTime pubdate { get; set; }
public bool IsDisable { get; set; }
}
}
MVC自带的的Models中类:
namespace MkMis.Web.Models
{
/// <summary>
/// 通知通告类
/// </summary>
public class Notice
{
[Required(ErrorMessage = "必须输入标题")]
public string Title { get; set; }
[Required(ErrorMessage = "必须输入内容")]
public string Content { get; set; }
[Required(ErrorMessage = "必须输入发布人")]
public string publisher { get; set; }
[Required(ErrorMessage = "必须输入发行日期")]
public DateTime pubdate { get; set; }
public bool IsDisable { get; set; }
}
}
页面:
@*@model MkMis.Safety.Domain.Model.Notice*@
@model MkMis.Web.Models.Notice
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>WelNoticeAdd</title>
<link href="~/lib/css/notice_style.css" rel="stylesheet" type="text/css" />
<script src="~/lib/jquery/jquery-1.5.2.js" type="text/javascript"></script>
<script src="@Url.Content("~/lib/jquery-validation/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/lib/jquery-validation/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../ckeditor/ckfinder.js"></script>
</head>
<