public ActionResult EditorAjax(int id) { ServiceProvider serviceprovider = null; if (id > 0) { //find an existing serviceprovider from database serviceprovider = serviceproviderRepository.Find(id); if (serviceprovider == null) { //throw an exception if id is provided but data does not exist in database return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound, "ServiceProvider not found")); } } else { //create a new instance if id is not provided serviceprovider = new ServiceProvider(); } //return the html of editor to display on popup return(Content(this.RenderPartialViewToString(Constants.PartialViews.CreateOrEdit, serviceprovider))); }