private bool ValidateCustomer(CustomerViewModel model) { var context = new SampleEntities(); return !context.Customers.Any(c => c.LastName.ToLower() == model.LastName.ToLower() && c.FirstName.ToLower() == model.FirstName.ToLower() && (model.MiddleName == null ? c.MiddleName == null : c.MiddleName.ToLower() == model.MiddleName.ToLower()) && c.ID != model.CustomerId); }
public JsonResult CheckDuplicateCustomerName(CustomerViewModel model) { return Json(ValidateCustomer(model), JsonRequestBehavior.AllowGet); }