public BsJsonResult New(ContributorNewModel model) { var status = BsResponseStatus.Success; var row = string.Empty; var msg = string.Empty; try { if (ModelState.IsValid) { var rowModel = repo.Create(model); var groupEditorModel = new GroupEditorModel { Contributors3 = new BsEditorTabModel <ContributorRowModel, ContributorSearchModel, ContributorNewModel> { Grid = new BsGridModel <ContributorRowModel> { Items = new List <ContributorRowModel> { rowModel } } } }; var viewModel = new GroupEditorViewModel() { Editor2 = groupEditorModel }; row = this.BsRenderPartialView("_Editors", viewModel); } else { return(new BsJsonResult( new Dictionary <string, object> { { "Errors", ModelState.GetErrors() } }, BsResponseStatus.ValidationError)); } } catch (Exception ex) { msg = Resource.ServerError; status = BsResponseStatus.ServerError; } return(new BsJsonResult(new { Row = row }, status, msg)); }
public BsJsonResult New(BsToolbarModel <ContributorSearchModel, ContributorNewModel> model) { var msg = string.Empty; var status = BsResponseStatus.Success; var row = string.Empty; try { if (ModelState.IsValid) { var rowModel = _gridRepository.Create(model.New); var viewModel = _gridRepository.ToBsGridViewModel(rowModel).Wrap <ContributorsViewModel>(x => x.Grid); row = this.BsRenderPartialView("Grid/_Grid", viewModel); } else { return(new BsJsonResult( new Dictionary <string, object> { { "Errors", ModelState.GetErrors() } }, BsResponseStatus.ValidationError)); } } catch (Exception ex) { msg = Resource.ServerError; status = BsResponseStatus.ServerError; } return(new BsJsonResult(new { Row = row }, status, msg)); }