public ActionResult UpdateCategory([DataSourceRequest] DataSourceRequest request, ProductModel productModel) { if (productModel != null && ModelState.IsValid) { var updated = siteRepository.AddCategory(productModel); //if(productModel.Category == null) //{ // this.ModelState.AddModelError("111111", "Please choose a role"); //} //if (updated == null) //{ // this.ModelState.AddModelError("2222222", "Role is already assigned to user"); //} } return(this.Json(siteRepository.GetAllProducts().ToDataSourceResult(request, this.ModelState))); }