I have my Gift Controller with an action result which takes a GiftViewModel in argument tu check the model state.
I just added a LoginModel property to GiftViewModel. And I would like to test the modelState of just this property.
GiftViewModel.cs:
public class GiftViewModel
{
public LoginModel login { get; set; }
[...]
}
GiftController.cs
//
// POST: /Gift/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(GiftViewModel model, string returnUrl)
{
// here instead of the overall modelstate
// I would like to check only the modestate of the login property
// of my model
if (ModelState.IsValid && WebSecurity.Login(model.login.Email, model.login.Password, persistCookie: model.login.RememberMe))
{
return View("Index", model);
}
return View("Index", model);
}
How can I manage it ?