例如这样的
if (DB.posts.Any(x=> x.coursecode == ps.coursecode && x.title == ps.title))
{
ViewBag.Error = "Post Title And Course Code Already Exist";
**code stop there and not run else**
}
else
{
DB.posts.Add(ps);
DB.SaveChanges();
ViewBag.Success = "Post Added Succesfully!";
}
return View();
我想根据条件在视图上显示一条消息,但是在视图中显示了两条消息。所以我该怎么做才能只显示一条消息!