public async Task <IActionResult> Insert(UserApiModel model) { if (string.IsNullOrEmpty(model.Password)) { ModelState.AddModelError("", "Password is required"); } if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } if (ModelState.IsValid) { var userapi = model.ToEntity(); var keys = HashPassword(model.Password); userapi.Password = keys.hashpassword; userapi.PrivateKey = keys.privatekey; await _userApiService.InsertUserApi(userapi); return(new NullJsonResult()); } return(ErrorForKendoGridJson(ModelState)); }