public ActionResult ProjectFileDelete(Guid?id) { int UserIDX = db_Accounts.GetUserIDX(); //get project, then org to check permissions T_OE_DOCUMENTS doc = db_EECIP.GetT_OE_DOCUMENTS_ByID(id.ConvertOrDefault <Guid>()); if (doc != null) { T_OE_PROJECTS _project = db_EECIP.GetT_OE_PROJECTS_ByIDX(doc.PROJECT_IDX); if (_project != null) { //actual permissions check if (db_Accounts.UserCanEditOrgIDX(UserIDX, _project.ORG_IDX.ConvertOrDefault <Guid>()) || User.IsInRole("Admins")) { int SuccID = db_EECIP.DeleteT_OE_DOCUMENTS(id.ConvertOrDefault <Guid>()); if (SuccID > 0) { TempData["Success"] = "File removed."; return(RedirectToAction("ProjectDetails", "Dashboard", new { id = _project.PROJECT_IDX })); } } TempData["Error"] = "Unable to delete document."; return(RedirectToAction("ProjectDetails", "Dashboard", new { id = _project.PROJECT_IDX })); } } TempData["Error"] = "Unable to delete document."; return(RedirectToAction("ProjectDetails", "Dashboard")); }
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.")); } }
public JsonResult ProjectsDelete(IEnumerable <Guid> id) { int UserIDX = db_Accounts.GetUserIDX(); if (id == null || id.Count() == 0) { return(Json("No record selected to delete")); } else { foreach (var id1 in id) { //CHECK PERMISSIONS T_OE_PROJECTS p = db_EECIP.GetT_OE_PROJECTS_ByIDX(id1); if (p != null) { List <T_OE_ORGANIZATION> orgs = db_EECIP.GetT_OE_PROJECT_ORGS_ByProject(p.PROJECT_IDX); if (orgs != null) { if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgList(db_Accounts.GetUserIDX(), orgs)) { int SuccID = db_EECIP.DeleteT_OE_PROJECTS(id1); if (SuccID > 0) { //SUCCESS - now delete from Azure (need to concat proj and all proj orgs foreach (T_OE_ORGANIZATION _org in orgs) { AzureSearch.DeleteSearchIndexKey(id1.ToString() + "_" + _org.ORG_IDX.ToString()); } } else { return(Json("Unable to delete project.")); } } } } } //if got this far, success return(Json("Success")); } }
public ActionResult ImportData(vmAdminImportData model) { int UserIDX = db_Accounts.GetUserIDX(); //set dictionaries used to store stuff in memory Dictionary <string, int> colMapping = new Dictionary <string, int>(); //identifies the column number for each field to be imported //initialize variables bool headInd = true; bool anyError = false; //loop through each row foreach (string row in model.IMPORT_BLOCK.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { //split row's columns into string array string[] cols = row.Split(new char[] { '\t' }, StringSplitOptions.None); if (cols.Length > 0) //skip blank rows { if (headInd) { //********************************************************** //HEADER ROW - LOGIC TO DETERMINE WHAT IS IN EACH COLUMN //********************************************************** colMapping = Utils.GetColumnMapping("P", cols); headInd = false; model.projects = new List <ProjectImportType>(); } else { //********************************************************** //NOT HEADER ROW - READING IN VALUES //********************************************************** var colList = cols.Select((value, index) => new { value, index }); var colDataIndexed = (from f in colMapping join c in colList on f.Value equals c.index select new { _Name = f.Key, _Val = c.value }).ToList(); Dictionary <string, string> fieldValuesDict = new Dictionary <string, string>(); //identifies the column number for each field to be imported //loop through all values and insert to list foreach (var c in colDataIndexed) { fieldValuesDict.Add(c._Name, c._Val); } //VALIDATE ROW AND INSERT TO LOCAL OBJECT ProjectImportType p = db_EECIP.InsertOrUpdate_T_OE_PROJECT_local(UserIDX, fieldValuesDict); if (p.VALIDATE_CD == false) { anyError = true; } model.projects.Add(p); } } } //end each row //if no errors, just import. otherwise if (!anyError) { foreach (ProjectImportType ps in model.projects) { //import projects T_OE_PROJECTS x = ps.T_OE_PROJECT; Guid? ProjectIDX = db_EECIP.InsertUpdatetT_OE_PROJECTS(x.PROJECT_IDX, x.ORG_IDX, x.PROJ_NAME, x.PROJ_DESC, x.MEDIA_TAG, x.START_YEAR, x.PROJ_STATUS, x.DATE_LAST_UPDATE, x.RECORD_SOURCE, x.PROJECT_URL, x.MOBILE_IND, x.MOBILE_DESC, x.ADV_MON_IND, x.ADV_MON_DESC, x.BP_MODERN_IND, x.BP_MODERN_DESC, x.COTS, x.VENDOR, x.PROJECT_CONTACT, null, true, false, UserIDX, x.IMPORT_ID, true); //import features if (ps.FEATURES != null) { foreach (string f in ps.FEATURES.Split('|')) { if (f.Length > 0) { db_EECIP.InsertT_OE_PROJECT_TAGS(ProjectIDX.ConvertOrDefault <Guid>(), "Project Feature", f, UserIDX); } } } //import program areas if (ps.PROGRAM_AREAS != null) { foreach (string f in ps.PROGRAM_AREAS.Split('|')) { if (f.Length > 0) { db_EECIP.InsertT_OE_PROJECT_TAGS(ProjectIDX.ConvertOrDefault <Guid>(), "Program Area", f, UserIDX); } } } } //update azure search AzureSearch.PopulateSearchIndexProject(null); //clear form model.IMPORT_BLOCK = ""; model.projects = null; TempData["Success"] = "Data imported successfully"; } return(View(model)); }