ServerSide Validation through validation object
This commit is contained in:
@ -43,7 +43,17 @@ namespace Vidly.Controllers
|
||||
[HttpPost]
|
||||
public ActionResult Save(Customer customer)
|
||||
{
|
||||
if(customer.Id==0)
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var viewModel = new CustomerFormViewModel
|
||||
{
|
||||
Customer = customer,
|
||||
MembershipTypes = _context.MembershipTypes.ToList()
|
||||
};
|
||||
return View("CustomerForm",viewModel);
|
||||
}
|
||||
|
||||
if (customer.Id==0)
|
||||
_context.Customers.Add(customer);
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user