示例#1
0
        //PULA clicked from Guest log in - limited view
        //GET: /Contributor_Details/11
        public PartialViewResult Contributor_Details(int shapeId)
        {
            BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
            var request = new RestRequest();

            //get the ACTIVE_INGREDIENT_PULA -- not published yet, only created for contibutors to look at
            request.Resource = "/PULAs/POI/{shapeId}?publishedDate={date}";
            request.RootElement = "ACTIVE_INGREDIENT_PULA";
            request.AddParameter("shapeId", shapeId, ParameterType.UrlSegment);
            ACTIVE_INGREDIENT_PULA thisPULA = serviceCaller.Execute<ACTIVE_INGREDIENT_PULA>(request);

            //store shape id to pass on
            ViewData["shapeId"] = shapeId;

            //get the PULA_LIMITATIONs
            request = new RestRequest();
            request.Resource = "PULAs/{pulaID}/PULALimitations?ActiveDate={date}";
            request.RootElement = "ArrayOfPULA_LIMITATIONS";
            request.AddParameter("pulaID", thisPULA.PULA_ID, ParameterType.UrlSegment);
            List<PULA_LIMITATIONS> PULALimitationList = serviceCaller.Execute<List<PULA_LIMITATIONS>>(request);

            //to store each row in the table for display
            List<PULALimitation> PubPulaLists = new List<PULALimitation>();
            //get all the Limitation parts
            foreach (PULA_LIMITATIONS pl in PULALimitationList)
            {
                PULALimitation thisPubPULA = new PULALimitation();
                if (pl.ACTIVE_INGREDIENT_ID != null && pl.ACTIVE_INGREDIENT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/ActiveIngredients?aiID={activeIngredientID}&publishedDate={date}";
                    request.RootElement = "ArrayOfACTIVE_INGREDIENT";
                    request.AddParameter("activeIngredientID", pl.ACTIVE_INGREDIENT_ID, ParameterType.UrlSegment);
                    List<ACTIVE_INGREDIENT> aiList = serviceCaller.Execute<List<ACTIVE_INGREDIENT>>(request);
                    //give me newest version
                    ACTIVE_INGREDIENT thisAI = aiList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.AI = thisAI.INGREDIENT_NAME;
                    thisPubPULA.AI_ID = thisAI.ID.ToString();
                }
                if (pl.PRODUCT_ID != null && pl.PRODUCT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/Products?ProductID={productID}&publishedDate={date}";
                    request.RootElement = "ArrayOfPRODUCT";
                    request.AddParameter("productID", pl.PRODUCT_ID, ParameterType.UrlSegment);
                    List<PRODUCT> prodList = serviceCaller.Execute<List<PRODUCT>>(request);
                    //give me newest version
                    PRODUCT thisprod = prodList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.Product = thisprod.PRODUCT_NAME;
                    thisPubPULA.Prod_ID = thisprod.ID.ToString();
                    thisPubPULA.Prod_RegNum = thisprod.PRODUCT_REGISTRATION_NUMBER;
                }

                //get crop use
                request = new RestRequest();
                request.Resource = "/CropUses?CropUseID={cropUseID}&publishedDate={date}";
                request.RootElement = "ArrayOfCROP_USE";
                request.AddParameter("cropUseID", pl.CROP_USE_ID, ParameterType.UrlSegment);
                List<CROP_USE> cuList = serviceCaller.Execute<List<CROP_USE>>(request);
                //give me the newest version
                CROP_USE thisCropUse = cuList.OrderByDescending(cu => cu.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.CropUse = thisCropUse.USE;
                thisPubPULA.CropUse_ID = thisCropUse.ID.ToString();

                //get application Method
                APPLICATION_METHOD thisAppMethod = GetApplicationMethod(pl.APPLICATION_METHOD_ID);
                //store in model
                thisPubPULA.AppMethod = thisAppMethod.METHOD;
                thisPubPULA.AppMeth_ID = thisAppMethod.ID.ToString();

                //get formulation
                request = new RestRequest();
                request.Resource = "/Formulations?FormulationID={formulationID}&publishedDate={date}";
                request.RootElement = "ArrayOfFORMULATION";
                request.AddParameter("formulationID", pl.FORMULATION_ID, ParameterType.UrlSegment);
                List<FORMULATION> formList = serviceCaller.Execute<List<FORMULATION>>(request);
                //give me the newest version
                FORMULATION thisFormulation = formList.OrderByDescending(m => m.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Formulation = thisFormulation.FORM;
                thisPubPULA.Form_ID = thisFormulation.ID.ToString();

                //get limitation code
                request = new RestRequest();
                request.Resource = "/Limitations/{limitationID}?publishedDate={date}";
                request.RootElement = "ArrayOfLIMITATION";
                request.AddParameter("limitationID", pl.LIMITATION_ID, ParameterType.UrlSegment);
                List<LIMITATION> lList = serviceCaller.Execute<List<LIMITATION>>(request);
                //give me the newest version
                LIMITATION thislimitation = lList.OrderByDescending(l => l.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Code = thislimitation.CODE;
                thisPubPULA.Code_ID = thislimitation.ID.ToString();
                thisPubPULA.Limitation = thislimitation.LIMITATION1;

                PubPulaLists.Add(thisPubPULA);
            }

            ViewData["PULAlimitationList"] = PubPulaLists;

            ////need unique codes for the Code Limitation table...
            List<PULALimitation> uniqueList = PubPulaLists.GroupBy(p => p.Code).Select(g => g.First()).ToList();
            ViewData["UniqueCodes"] = uniqueList;

            return PartialView(thisPULA);
        }
示例#2
0
        //pula was clicked in mapper, show info in popup
        // GET: /PULA_Details/11
        public PartialViewResult PULA_Details(int shapeId, DateTime date, string status)
        {
            if (status != null)
                ViewData["UpdatePULA"] = "updated";

            BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
            var request = new RestRequest();

            //get the ACTIVE_INGREDIENT_PULA
            request.Resource = "/PULAs/POI/{shapeId}?publishedDate={date}";
            request.RootElement = "ACTIVE_INGREDIENT_PULA";
            request.AddParameter("shapeId", shapeId, ParameterType.UrlSegment);
            ACTIVE_INGREDIENT_PULA thisPULA = serviceCaller.Execute<ACTIVE_INGREDIENT_PULA>(request);

            if (thisPULA.EFFECTIVE_DATE != null)
            {
                string monthYear = GetThisMonth(thisPULA.EFFECTIVE_DATE.Value.Month) + thisPULA.EFFECTIVE_DATE.Value.Year;
                ViewData["EffectMonthYr"] = monthYear;
            }

            //pull out the comments '[Name|Org|omment][Name2|Org2|comment2]
            if (thisPULA.COMMENTS != null)
            {
                string[] comments = thisPULA.COMMENTS.Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);//Regex.Split(thisPULA.COMMENTS, "]");
                List<CommentsModel> allComments = new List<CommentsModel>();
                foreach (string c in comments)
                {
                    CommentsModel aComment = new CommentsModel();
                    string[] aCom = c.Split('|');
                    foreach (string ac in aCom)
                    {
                        aComment.Name = aCom[0];
                        aComment.Org = aCom[1];
                        aComment.Comment = aCom[2];
                    }
                    allComments.Add(aComment);
                }
                ViewData["Comments"] = allComments;
            }

            //get the Events
            request.Resource = "Events/{eventID}";
            request.RootElement = "EVENT";
            request.AddParameter("eventID", thisPULA.EVENT_ID, ParameterType.UrlSegment);
            EVENT anEvent = serviceCaller.Execute<EVENT>(request);
            ViewData["EventName"] = anEvent != null ?anEvent.NAME : "";

            //get the version info
            request = new RestRequest();
            request.Resource = "/Version/{entityID}";
            request.RootElement = "VERSION";
            request.AddParameter("entityID", thisPULA.VERSION_ID, ParameterType.UrlSegment);
            VERSION thisVersion = serviceCaller.Execute<VERSION>(request);
            ViewData["Version"] = thisVersion; //store to get created and expired dates

            //get the Users from Version
            //creator
            request = new RestRequest();
            request.Resource = "/Users/{userID}";
            request.RootElement = "ArrayOfUSER_";
            request.AddParameter("userID", thisVersion.CREATOR_ID, ParameterType.UrlSegment);
            List<USER_> creatList = serviceCaller.Execute<List<USER_>>(request);
            USER_ creator = creatList.FirstOrDefault();

            if (creator != null)
            {
                ViewData["CreatorName"] = creator.FNAME + " " + creator.LNAME;

                if (creator.ORGANIZATION_ID != 0 && creator.ORGANIZATION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Organizations/{organizationID}";
                    request.RootElement = "ORGANIZATION";
                    request.AddParameter("organizationID", creator.ORGANIZATION_ID, ParameterType.UrlSegment);
                    ORGANIZATION thisOrg = serviceCaller.Execute<ORGANIZATION>(request);
                    if (thisOrg != null)
                        ViewData["creatorOrg"] = thisOrg.NAME;
                }
                if (creator.DIVISION_ID != 0 && creator.DIVISION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Divisions/{divisionID}";
                    request.RootElement = "DIVISION";
                    request.AddParameter("divisionID", creator.DIVISION_ID, ParameterType.UrlSegment);
                    ViewData["creatorDiv"] = serviceCaller.Execute<DIVISION>(request).DIVISION_NAME;
                }
            }
            //Publisher
            if (thisVersion.PUBLISHER_ID != null && thisVersion.PUBLISHER_ID != 0)
            {
                request = new RestRequest();
                request.Resource = "/Users/{userID}";
                request.RootElement = "ArrayOfUSER_";
                request.AddParameter("userID", thisVersion.PUBLISHER_ID, ParameterType.UrlSegment);
                List<USER_> pubList = serviceCaller.Execute<List<USER_>>(request);
                USER_ publisher = pubList.FirstOrDefault();

                if (publisher.ORGANIZATION_ID != 0 && publisher.ORGANIZATION_ID != null)
                {
                    ViewData["publisherName"] = publisher.FNAME + " " + publisher.LNAME;

                    request = new RestRequest();
                    request.Resource = "/Organizations/{organizationID}";
                    request.RootElement = "ORGANIZATION";
                    request.AddParameter("organizationID", publisher.ORGANIZATION_ID, ParameterType.UrlSegment);
                    ORGANIZATION pubOrg = serviceCaller.Execute<ORGANIZATION>(request);
                    if (pubOrg != null)
                        ViewData["publisherOrg"] = pubOrg.NAME;
                }
                if (publisher.DIVISION_ID != 0 && publisher.DIVISION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Divisions/{divisionID}";
                    request.RootElement = "DIVISION";
                    request.AddParameter("divisionID", publisher.DIVISION_ID, ParameterType.UrlSegment);
                    ViewData["publisherDiv"] = serviceCaller.Execute<DIVISION>(request).DIVISION_NAME;
                }
            }

            //Expirer
            if (thisVersion.EXPIRER_ID != null && thisVersion.EXPIRER_ID != 0)
            {
                request = new RestRequest();
                request.Resource = "/Users/{userID}";
                request.RootElement = "ArrayOfUSER_";
                request.AddParameter("userID", thisVersion.EXPIRER_ID, ParameterType.UrlSegment);
                List<USER_> expList = serviceCaller.Execute<List<USER_>>(request);
                USER_ expirer = expList.FirstOrDefault();

                if (expirer.ORGANIZATION_ID != 0 && expirer.ORGANIZATION_ID != null)
                {
                    ViewData["expirerName"] = expirer.FNAME + " " + expirer.LNAME;

                    request = new RestRequest();
                    request.Resource = "/Organizations/{organizationID}";
                    request.RootElement = "ORGANIZATION";
                    request.AddParameter("organizationID", expirer.ORGANIZATION_ID, ParameterType.UrlSegment);
                    ORGANIZATION expOrg = serviceCaller.Execute<ORGANIZATION>(request);
                    if (expOrg != null)
                        ViewData["expirerOrg"] = expOrg.NAME;
                }
                if (expirer.DIVISION_ID != 0 && expirer.DIVISION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Divisions/{divisionID}";
                    request.RootElement = "DIVISION";
                    request.AddParameter("divisionID", expirer.DIVISION_ID, ParameterType.UrlSegment);
                    ViewData["expirerDiv"] = serviceCaller.Execute<DIVISION>(request).DIVISION_NAME;
                }
            }

            //get the PULA species
            request = new RestRequest();
            request.Resource = "/ActiveIngredientPULA/{activeIngredientPULAID}/Species";
            //request.RootElement = "ArrayOfSPECIES_ACTIVE_INGREDIENT_PULA";
            request.RootElement = "ArrayOfSPECIES";
            request.AddParameter("activeIngredientPULAID", thisPULA.PULA_ID, ParameterType.UrlSegment);
            SpeciesList PULAspp = serviceCaller.Execute<SpeciesList>(request);
            if (PULAspp != null)
            {
                ViewData["PULASpp"] = PULAspp.SPECIES.OrderBy(x => x.COMNAME).ToList();
            }
            else
            {
                ViewData["TESSError"] = true;
            }
            //get the PULA_LIMITATIONs
            request = new RestRequest();
            request.Resource = "PULAs/{pulaID}/PULALimitations?ActiveDate={date}";
            request.RootElement = "ArrayOfPULA_LIMITATIONS";
            request.AddParameter("pulaID", thisPULA.PULA_ID, ParameterType.UrlSegment);
            List<PULA_LIMITATIONS> PULALimitationList = serviceCaller.Execute<List<PULA_LIMITATIONS>>(request);

            //to display each row in the table, use model
            List<PULALimitation> PubPulaLists = new List<PULALimitation>();

            //get all the Limitation parts
            foreach (PULA_LIMITATIONS pl in PULALimitationList)
            {
                PULALimitation thisPubPULA = new PULALimitation();
                if (pl.ACTIVE_INGREDIENT_ID != null && pl.ACTIVE_INGREDIENT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/ActiveIngredients?aiID={activeIngredientID}&publishedDate={date}";
                    request.RootElement = "ArrayOfACTIVE_INGREDIENT";
                    request.AddParameter("activeIngredientID", pl.ACTIVE_INGREDIENT_ID, ParameterType.UrlSegment);
                    List<ACTIVE_INGREDIENT> aiList = serviceCaller.Execute<List<ACTIVE_INGREDIENT>>(request);
                    //give me newest version
                    ACTIVE_INGREDIENT thisAI = aiList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.AI = thisAI.INGREDIENT_NAME;
                }
                if (pl.PRODUCT_ID != null && pl.PRODUCT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/Products?ProductID={productID}&publishedDate={date}";
                    request.RootElement = "ArrayOfPRODUCT";
                    request.AddParameter("productID", pl.PRODUCT_ID, ParameterType.UrlSegment);
                    List<PRODUCT> prodList = serviceCaller.Execute<List<PRODUCT>>(request);
                    //give me newest version
                    PRODUCT thisprod = prodList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.Product = thisprod.PRODUCT_NAME;
                    thisPubPULA.Prod_RegNum = thisprod.PRODUCT_REGISTRATION_NUMBER;
                }

                //get crop use
                request = new RestRequest();
                request.Resource = "/CropUses?CropUseID={cropUseID}&publishedDate={date}";
                request.RootElement = "ArrayOfCROP_USE";
                request.AddParameter("cropUseID", pl.CROP_USE_ID, ParameterType.UrlSegment);
                List<CROP_USE> cuList = serviceCaller.Execute<List<CROP_USE>>(request);
                //give me the newest version
                CROP_USE thisCropUse = cuList.OrderByDescending(cu => cu.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.CropUse = thisCropUse.USE;

                //get application Method and store in model
                thisPubPULA.AppMethod = GetApplicationMethod(pl.APPLICATION_METHOD_ID).METHOD;

                //get formulation
                request = new RestRequest();
                request.Resource = "/Formulations?FormulationID={formulationID}&publishedDate={date}";
                request.RootElement = "ArrayOfFORMULATION";
                request.AddParameter("formulationID", pl.FORMULATION_ID, ParameterType.UrlSegment);
                List<FORMULATION> formList = serviceCaller.Execute<List<FORMULATION>>(request);
                //give me the newest version
                FORMULATION thisFormulation = formList.OrderByDescending(m => m.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Formulation = thisFormulation.FORM;

                //get limitation code
                request = new RestRequest();
               // request.Resource = "/Limitations?limitationID={limitationID}&publishedDate={date}";
                request.Resource = "/Limitations/{limitationID}?publishedDate={date}";
                request.RootElement = "ArrayOfLIMITATION";
                request.AddParameter("limitationID", pl.LIMITATION_ID, ParameterType.UrlSegment);
                List<LIMITATION> lList = serviceCaller.Execute<List<LIMITATION>>(request);
                //give me the newest version
                LIMITATION thislimitation = lList.OrderByDescending(l => l.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Code = thislimitation.CODE;
                thisPubPULA.Limitation = thislimitation.LIMITATION1;

                PubPulaLists.Add(thisPubPULA);
            }

            ViewData["PULAlimitationList"] = PubPulaLists;

            //get months and years lists
            ViewBag.Months = GetMonthsList();
            ViewBag.Years = GetYearList();

            //get logged in User
            ViewData["loggedIn"] = GetLoggedInUser();

            return PartialView(thisPULA);
        }
示例#3
0
        //PULA was determined to be Created but not Published, can be edited
        // GET: /PULA_Publish/11 (edit page -- can be published or updated/saved)
        public PartialViewResult PULA_Edit(int shapeId, DateTime? date)
        {
            BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
            var request = new RestRequest();

            //get the ACTIVE_INGREDIENT_PULA
            request.Resource = "/PULAs/POI/{shapeId}?publishedDate={date}";
            request.RootElement = "ACTIVE_INGREDIENT_PULA";
            request.AddParameter("shapeId", shapeId, ParameterType.UrlSegment);
            ACTIVE_INGREDIENT_PULA thisPULA = serviceCaller.Execute<ACTIVE_INGREDIENT_PULA>(request);

            //store the logged in user
            USER_ loggedIn = GetLoggedInUser();
            ViewData["User"] = loggedIn;
            ViewData["shapeId"] = shapeId; //store shape id to pass on

            //get the version info
            request = new RestRequest();
            request.Resource = "/Version/{entityID}";
            request.RootElement = "VERSION";
            request.AddParameter("entityID", thisPULA.VERSION_ID, ParameterType.UrlSegment);
            VERSION thisVersion = serviceCaller.Execute<VERSION>(request);
            ViewData["Version"] = thisVersion; //store to get created and expired dates

            //get the Users from Version
            //creator
            request = new RestRequest();
            request.Resource = "/Users/{userID}";
            request.RootElement = "ArrayOfUSER_";
            request.AddParameter("userID", thisVersion.CREATOR_ID, ParameterType.UrlSegment);
            List<USER_> creatList = serviceCaller.Execute<List<USER_>>(request);
            USER_ creator = creatList.FirstOrDefault();

            if (creator != null)
            {
                ViewData["CreatorName"] = creator.FNAME + " " + creator.LNAME;

                if (creator.ORGANIZATION_ID != 0 && creator.ORGANIZATION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Organizations/{organizationID}";
                    request.RootElement = "ORGANIZATION";
                    request.AddParameter("organizationID", creator.ORGANIZATION_ID, ParameterType.UrlSegment);
                    ORGANIZATION cOrg = serviceCaller.Execute<ORGANIZATION>(request);
                    if (cOrg != null)
                        ViewData["creatorOrg"] = cOrg.NAME;
                }
                if (creator.DIVISION_ID != 0 && creator.DIVISION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Divisions/{divisionID}";
                    request.RootElement = "DIVISION";
                    request.AddParameter("divisionID", creator.DIVISION_ID, ParameterType.UrlSegment);
                    ViewData["creatorDiv"] = serviceCaller.Execute<DIVISION>(request).DIVISION_NAME;
                }
            }

            //Expirer
            if (thisVersion.EXPIRER_ID != null && thisVersion.EXPIRER_ID != 0)
            {
                request = new RestRequest();
                request.Resource = "/Users/{userID}";
                request.RootElement = "ArrayOfUSER_";
                request.AddParameter("userID", thisVersion.EXPIRER_ID, ParameterType.UrlSegment);
                List<USER_> expList = serviceCaller.Execute<List<USER_>>(request);
                USER_ expirer = expList.FirstOrDefault();

                if (expirer.ORGANIZATION_ID != 0 && expirer.ORGANIZATION_ID != null)
                {
                    ViewData["expirerName"] = expirer.FNAME + " " + expirer.LNAME;

                    request = new RestRequest();
                    request.Resource = "/Organizations/{organizationID}";
                    request.RootElement = "ORGANIZATION";
                    request.AddParameter("organizationID", expirer.ORGANIZATION_ID, ParameterType.UrlSegment);
                    ORGANIZATION eOrg = serviceCaller.Execute<ORGANIZATION>(request);
                    if (eOrg != null)
                        ViewData["expirerOrg"] = eOrg.NAME;
                }
                if (expirer.DIVISION_ID != 0 && expirer.DIVISION_ID != null)
                {
                    request = new RestRequest();
                    request.Resource = "/Divisions/{divisionID}";
                    request.RootElement = "DIVISION";
                    request.AddParameter("divisionID", expirer.DIVISION_ID, ParameterType.UrlSegment);
                    ViewData["expirerDiv"] = serviceCaller.Execute<DIVISION>(request).DIVISION_NAME;
                }
            }

            //get the PULA species
            request = new RestRequest();
            request.Resource = "/ActiveIngredientPULA/{activeIngredientPULAID}/Species";
            request.RootElement = "ArrayOfSPECIES";
            request.AddParameter("activeIngredientPULAID", thisPULA.PULA_ID, ParameterType.UrlSegment);
            SpeciesList PULAspp = serviceCaller.Execute<SpeciesList>(request);
            if (PULAspp != null)
            {
                ViewData["PULASpp"] = PULAspp.SPECIES.OrderBy(x => x.COMNAME).ToList();
            }
            else
            {
                ViewData["TESSError"] = true;
            }
            //get lists for AI, Modifiers, Crop Use, Code, AI CLass and CAS NOT WORKING RIGHT NOW 6.27.13
            request = new RestRequest();
            request.Resource = "ActiveIngredients?status={status}&date={date}";
            request.RootElement = "ArrayOfACTIVE_INGREDIENT";
            request.AddParameter("status", "published", ParameterType.UrlSegment);
            List<ACTIVE_INGREDIENT> AllAIs = serviceCaller.Execute<List<ACTIVE_INGREDIENT>>(request);
            ViewData["AIList"] = AllAIs;

            request = new RestRequest();
            request.Resource = "CropUses?status={status}&date={date}";
            request.RootElement = "ArrayOfCROP_USE";
            request.AddParameter("status", "published", ParameterType.UrlSegment);
            List<CROP_USE> CUList = serviceCaller.Execute<List<CROP_USE>>(request);
            ViewData["CUList"] = CUList.OrderBy(x => x.USE).ToList();

            request = new RestRequest();
            request.Resource = "ApplicationMethods?status={status}&date={date}";
            request.RootElement = "ArrayOfAPPLICATION_METHOD";
            request.AddParameter("status", "published", ParameterType.UrlSegment);
            List<APPLICATION_METHOD> appMethodsList = serviceCaller.Execute<List<APPLICATION_METHOD>>(request);
            ViewData["AppMethodsList"] = appMethodsList.OrderBy(x => x.METHOD).ToList();

            request = new RestRequest();
            request.Resource = "Formulations?status={status}&date={date}";
            request.RootElement = "ArrayOfFORMULATION";
            request.AddParameter("status", "published", ParameterType.UrlSegment);
            List<FORMULATION> formulationsList = serviceCaller.Execute<List<FORMULATION>>(request);
            ViewData["FormulationsList"] = formulationsList.OrderBy(x => x.FORM).ToList();

            request = new RestRequest();
            request.Resource = "Limitations?status={status}&date={date}";
            request.RootElement = "ArrayOfLIMITATION";
            request.AddParameter("status", "published", ParameterType.UrlSegment);
            List<LIMITATION> CodeList = serviceCaller.Execute<List<LIMITATION>>(request);
            ViewData["CodeList"] = CodeList.OrderBy(x => x.CODE).ToList();

            //get the PULA_LIMITATIONs
            request = new RestRequest();
            request.Resource = "PULAs/{pulaID}/PULALimitations?ActiveDate={date}";
            request.RootElement = "ArrayOfPULA_LIMITATIONS";
            request.AddParameter("pulaID", thisPULA.PULA_ID, ParameterType.UrlSegment);
            List<PULA_LIMITATIONS> PULALimitationList = serviceCaller.Execute<List<PULA_LIMITATIONS>>(request);

            //to store each row in the table for display
            List<PULALimitation> PubPulaLists = new List<PULALimitation>();
            //get all the Limitation parts
            foreach (PULA_LIMITATIONS pl in PULALimitationList)
            {
                PULALimitation thisPubPULA = new PULALimitation();
                thisPubPULA.PulaLimitID = pl.PULA_LIMITATION_ID.ToString();
                if (pl.ACTIVE_INGREDIENT_ID != null && pl.ACTIVE_INGREDIENT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/ActiveIngredients?aiID={activeIngredientID}&publishedDate={date}";
                    request.RootElement = "ArrayOfACTIVE_INGREDIENT";
                    request.AddParameter("activeIngredientID", pl.ACTIVE_INGREDIENT_ID, ParameterType.UrlSegment);
                    List<ACTIVE_INGREDIENT> aiList = serviceCaller.Execute<List<ACTIVE_INGREDIENT>>(request);
                    //give me newest version
                    ACTIVE_INGREDIENT thisAI = aiList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.AI = thisAI.INGREDIENT_NAME;
                    thisPubPULA.AI_ID = thisAI.ACTIVE_INGREDIENT_ID.ToString();
                }
                if (pl.PRODUCT_ID != null && pl.PRODUCT_ID != 0)
                {
                    //get Active Ingredient
                    request = new RestRequest();
                    request.Resource = "/Products?ProductID={productID}&publishedDate={date}";
                    request.RootElement = "ArrayOfPRODUCT";
                    request.AddParameter("productID", pl.PRODUCT_ID, ParameterType.UrlSegment);
                    List<PRODUCT> prodList = serviceCaller.Execute<List<PRODUCT>>(request);
                    //give me newest version
                    PRODUCT thisprod = prodList.OrderByDescending(a => a.VERSION_ID).FirstOrDefault();
                    //store in model
                    thisPubPULA.Product = thisprod.PRODUCT_NAME;
                    thisPubPULA.Prod_ID = thisprod.PRODUCT_ID.ToString();
                    thisPubPULA.Prod_RegNum = thisprod.PRODUCT_REGISTRATION_NUMBER;
                }

                //get crop use
                request = new RestRequest();
                request.Resource = "/CropUses?CropUseID={cropUseID}&publishedDate={date}";
                request.RootElement = "ArrayOfCROP_USE";
                request.AddParameter("cropUseID", pl.CROP_USE_ID, ParameterType.UrlSegment);
                List<CROP_USE> cuList = serviceCaller.Execute<List<CROP_USE>>(request);
                //give me the newest version
                CROP_USE thisCropUse = cuList.OrderByDescending(cu => cu.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.CropUse = thisCropUse.USE;
                thisPubPULA.CropUse_ID = thisCropUse.CROP_USE_ID.ToString();

                //get application method
                APPLICATION_METHOD thisAppMethod = GetApplicationMethod(pl.APPLICATION_METHOD_ID);
                //store in model
                thisPubPULA.AppMethod = thisAppMethod.METHOD;
                thisPubPULA.AppMeth_ID = thisAppMethod.APPLICATION_METHOD_ID.ToString();

                //get formulation
                request = new RestRequest();
                request.Resource = "/Formulations?FormulationID={formulationID}&publishedDate={date}";
                request.RootElement = "ArrayOfFORMULATION";
                request.AddParameter("formulationID", pl.FORMULATION_ID, ParameterType.UrlSegment);
                List<FORMULATION> formList = serviceCaller.Execute<List<FORMULATION>>(request);
                //give me the newest version
                FORMULATION thisFormulation = formList.OrderByDescending(m => m.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Formulation = thisFormulation.FORM;
                thisPubPULA.Form_ID = thisFormulation.FORMULATION_ID.ToString();

                //get limitation code
                request = new RestRequest();
                request.Resource = "/Limitations/{limitationID}?publishedDate={date}";
                request.RootElement = "ArrayOfLIMITATION";
                request.AddParameter("limitationID", pl.LIMITATION_ID, ParameterType.UrlSegment);
                List<LIMITATION> lList = serviceCaller.Execute<List<LIMITATION>>(request);
                //give me the newest version
                LIMITATION thislimitation = lList.OrderByDescending(l => l.VERSION_ID).FirstOrDefault();
                //store in model
                thisPubPULA.Code = thislimitation.CODE;
                thisPubPULA.Code_ID = thislimitation.LIMITATION_ID.ToString();
                thisPubPULA.Limitation = thislimitation.LIMITATION1;

                PubPulaLists.Add(thisPubPULA);
            }

            ViewData["PULAlimitationList"] = PubPulaLists;

            //get Events
            request = new RestRequest();
            request.Resource = "Events/";
            request.RootElement = "ArrayOfEVENT";
            ViewData["EventList"] = serviceCaller.Execute<List<EVENT>>(request);

            //get months and years lists (1 each for Effective Data and Expiration Date) (pass chosen if there is one)
            if (thisPULA.EFFECTIVE_DATE != null)
            {
                ViewBag.EffMonths = new SelectList(GetMonthsList(), "Value", "Text", ((DateTime)thisPULA.EFFECTIVE_DATE).Month);
                ViewBag.EffYears = GetEffectYears().Select(x => new SelectListItem
                {
                    Selected = x.Text == ((DateTime)thisPULA.EFFECTIVE_DATE).Year.ToString(),
                    Text = x.Text,
                    Value = x.Text.ToString()
                });
            }
            else
            {
                ViewBag.EffMonths = new SelectList(GetMonthsList(), "Value", "Text");
                ViewBag.EffYears = GetEffectYears().Select(x => new SelectListItem
                {
                    Text = x.Text,
                    Value = x.Text.ToString()
                });
            }
            if (thisVersion.EXPIRED_TIME_STAMP != null)
            {
                ViewBag.ExMonths = new SelectList(GetMonthsList(), "Value", "Text", ((DateTime)thisVersion.EXPIRED_TIME_STAMP).Month);
                ViewBag.ExYears = GetYearList().Select(x => new SelectListItem
                {
                    Selected = x.Text == ((DateTime)thisVersion.EXPIRED_TIME_STAMP).Year.ToString(),
                    Text = x.Text,
                    Value = x.Text.ToString()
                });
            }
            else
            {
                ViewBag.ExMonths = new SelectList(GetMonthsList(), "Value", "Text");
                ViewBag.ExYears = new SelectList(GetYearList(), "Value", "Text");
            }

            //get species
            request = new RestRequest();
            request.Resource = "/SimpleSpecies";
            request.RootElement = "ArrayOfSpecies";
            SpeciesList SppList = serviceCaller.Execute<SpeciesList>(request);

            ViewData["SpeciesListCom"] = SppList.SPECIES.OrderBy(X => X.COMNAME).ToList();
            ViewData["SpeciesListScie"] = SppList.SPECIES.OrderBy(x => x.SCINAME).ToList();
            ViewData["SpeciesListEntity"] = SppList.SPECIES.OrderBy(x => x.ENTITY_ID).ToList();

            //get logged in User
            ViewData["loggedIn"] = GetLoggedInUser();

            return PartialView(thisPULA);
        }