コード例 #1
0
        public JsonResult ProjectOrgDelete(string id, string id2)
        {
            if (id == null)
            {
                return(Json("No record selected to delete"));
            }
            else
            {
                Guid orgIDX  = Guid.Parse(id);
                Guid projIDX = Guid.Parse(id2);

                List <T_OE_ORGANIZATION> allPO = db_EECIP.GetT_OE_PROJECT_ORGS_ByProject(projIDX);
                if (allPO != null)
                {
                    //CHECK PERMISSIONS IF USER CAN EDIT PROJECT BASED ON ALL ORGS ASSOCIATED WITH PROJECT
                    int UserIDX = db_Accounts.GetUserIDX();
                    if (User.IsInRole("Admins") || db_Accounts.UserCanEditOrgList(UserIDX, allPO))
                    {
                        //FIND EXACT RECORD TO REMOVE
                        T_OE_PROJECT_ORGS po = db_EECIP.GetT_OE_PROJECT_ORGS_ByProj_Org(orgIDX, projIDX);
                        if (po != null)
                        {
                            int SuccID = db_EECIP.DeleteT_OE_PROJECT_ORGS(po.PROJECT_ORG_IDX);
                            if (SuccID > 0)
                            {
                                //SUCCESS - now delete from Azure
                                //now update the Azure search
                                db_EECIP.InsertUpdatetT_OE_PROJECTS(projIDX, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, true, false);
                                AzureSearch.DeleteSearchIndexKey(id2 + "_" + id);
                                return(Json("Success"));
                            }
                        }
                    }
                    else
                    {
                        return(Json("You don't have rights to remove ."));
                    }
                }
            }

            //if got this far, generic error
            return(Json("Unable to delete."));
        }
コード例 #2
0
        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"));
            }
        }