public JsonResult processReportPermissions(List <Spartan_Report_Permissions> list) { string respuesta = ""; bool token = _tokenManager.GenerateToken(); if (!token) { return(Json(null, JsonRequestBehavior.AllowGet)); } else { List <Spartan_Report_Permissions> listaOrginal = (List <Spartan_Report_Permissions>)Session["listaOrginal"]; _ISpartan_Report_PermissionsApiConsumer.SetAuthHeader(_tokenManager.Token); foreach (Spartan_Report_Permissions s in listaOrginal) { //buscando el elemento existente //var query = from firstItem in listaOrginal // join secondItem in list // on firstItem.ReportPermissionId equals secondItem.ReportPermissionId // where (s.ReportPermissionId == secondItem.ReportPermissionId) // select firstItem; bool containsItem = list != null && list.Any(item => item.ReportPermissionId == s.ReportPermissionId); if (containsItem == false) { respuesta = JsonConvert.SerializeObject(_ISpartan_Report_PermissionsApiConsumer.Delete(s.ReportPermissionId, null, null)); } } if (list != null) { foreach (Spartan_Report_Permissions s in list) { bool containsItem = listaOrginal.Any(item => item.ReportPermissionId == s.ReportPermissionId); if (containsItem) { respuesta = JsonConvert.SerializeObject(_ISpartan_Report_PermissionsApiConsumer.Update(s, null, null)); } else { respuesta = JsonConvert.SerializeObject(_ISpartan_Report_PermissionsApiConsumer.Insert(s, null, null)); } //return Json(_ISpartan_Format_PermissionsApiConsumer.Insert(s, null, null), JsonRequestBehavior.AllowGet); } } Spartane.Web.Helpers.MenuHelper.GetLatestMenu(); return(Json(true, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { try { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_Report_PermissionsApiConsumer.SetAuthHeader(_tokenManager.Token); //Spartan_Report_Permissions varSpartan_Report_Permissions = null; if (id.ToString() != "0") { } var result = _ISpartan_Report_PermissionsApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException) { return(Json(false, JsonRequestBehavior.AllowGet)); } }