I am trying to show the error message on view. Can you please suggest me the right approach to do this. I was thinking to add the data annotation dynamically but can't find any solution.
Thanks
[HttpPost]
public ActionResult AddBook(BooksModel booksModel)
{
try
{
booksModel.Account = _bookRepository.BookDetails(booksModel.Title,booksModel.RefCode, booksModel.DontHaveRefCode);
}
catch (FaultException faultException)
{
switch (faultException.Code.Name)
{
case "exc1":
// Show Error Message Here
return View("AddBook", booksModel);
default:
break;
}
}
return View("ConfirmBook", booksModel);
}