public ActionResult SaveData(DataTableImportMappingChangeViewModel datatableimportmappings) { if (datatableimportmappings.updated != null) { foreach (var updated in datatableimportmappings.updated) { _dataTableImportMappingService.Update(updated); } } if (datatableimportmappings.deleted != null) { foreach (var deleted in datatableimportmappings.deleted) { _dataTableImportMappingService.Delete(deleted); } } if (datatableimportmappings.inserted != null) { foreach (var inserted in datatableimportmappings.inserted) { _dataTableImportMappingService.Insert(inserted); } } _unitOfWork.SaveChanges(); return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); }
//[ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "Id,EntitySetName,FieldName,TypeName,SourceFieldName,DefaultValue,IsEnabled,RegularExpression")] DataTableImportMapping dataTableImportMapping) { if (ModelState.IsValid) { dataTableImportMapping.TrackingState = TrackingState.Modified; _dataTableImportMappingService.Update(dataTableImportMapping); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has update a DataTableImportMapping record"); return(RedirectToAction("Index")); } if (Request.IsAjaxRequest()) { var modelStateErrors = string.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage))); return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet)); } DisplayErrorMessage(); return(View(dataTableImportMapping)); }