public JsonResult ProjectsDelete(IEnumerable <Guid> RecordDeletebyId) { int UserIDX = db_Accounts.GetUserIDX(); if (RecordDeletebyId == null) { return(Json("No record selected to delete")); } else { foreach (var id in RecordDeletebyId) { //CHECK PERMISSIONS T_OE_PROJECTS p = db_EECIP.GetT_OE_PROJECTS_ByIDX(id); if (p != null) { if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgIDX(db_Accounts.GetUserIDX(), p.ORG_IDX.ConvertOrDefault <Guid>())) { int SuccID = db_EECIP.DeleteT_OE_PROJECTS(id); if (SuccID > 0) { //SUCCESS - now delete from Azure AzureSearch.DeleteSearchIndexProject(id); return(Json("Success")); } } } } //if got this far, general error return(Json("Unable to delete project.")); } }