Exemplo n.º 1
0
        public ActionResult MemberCreate(MemberCreateModel fc)
        {
            try
            {
                MEMBER newMember = new MEMBER();
                newMember.FNAME     = fc.FName;
                newMember.LNAME     = fc.LName;
                newMember.AGENCY_ID = fc.Agency_ID;
                newMember.PHONE     = fc.Phone;
                newMember.EMAIL     = fc.Email;
                newMember.RSSFEED   = fc.RSS_Feed;
                newMember.EMERGENCY_CONTACT_NAME  = fc.Emergency_ContactName;
                newMember.EMERGENCY_CONTACT_PHONE = fc.Emergency_ContactPhone;
                newMember.ROLE_ID  = fc.Role_ID;
                newMember.USERNAME = fc.UserName;

                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource = "Members/{pass}/addMember";
                request.AddParameter("pass", fc.Password, ParameterType.UrlSegment);
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <MEMBER>(newMember), ParameterType.RequestBody);

                MEMBER createdMember = serviceCaller.Execute <MEMBER>(request);

                return(RedirectToAction("MemberDE", new { id = createdMember.MEMBER_ID }));
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 2
0
        public PartialViewResult EventEdit(int id, EVENT anEvent)
        {
            try
            {
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);

                request.Resource      = "/Events/{entityId}";
                request.RequestFormat = DataFormat.Xml;
                request.AddParameter("entityId", id, ParameterType.UrlSegment);
                request.AddHeader("X-HTTP-Method-Override", "PUT");
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <EVENT>(anEvent), ParameterType.RequestBody);

                serviceCaller.Execute <EVENT>(request);

                //populate viewData for DetailsPV
                //get EVENT_TYPE.TYPE
                if (anEvent.EVENT_TYPE_ID != null && anEvent.EVENT_TYPE_ID != 0)
                {
                    ViewData["EventType"] = GetEventType(anEvent.EVENT_TYPE_ID);
                }

                //get EVENT_STATUS.STATUS
                if (anEvent.EVENT_STATUS_ID != null && anEvent.EVENT_STATUS_ID != 0)
                {
                    ViewData["EventStatus"] = GetEventStatus(anEvent.EVENT_STATUS_ID);
                }

                //get coordinator username
                if (anEvent.EVENT_COORDINATOR != null && anEvent.EVENT_COORDINATOR != 0)
                {
                    ViewData["MemUsername"] = GetMember(anEvent.EVENT_COORDINATOR);
                }

                return(PartialView("../Settings/Events/EventDetailsPV", anEvent));
            }
            catch (Exception e)
            {
                return(PartialView("../Shared/Error", e));
            }
        }
Exemplo n.º 3
0
        public ActionResult EventCreate(EVENT newEvent)
        {
            try
            {
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource      = "/Events/";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <EVENT>(newEvent), ParameterType.RequestBody);

                EVENT createdEvent = serviceCaller.Execute <EVENT>(request);

                return(RedirectToAction("EventDetails", new { id = createdEvent.EVENT_ID }));
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(HWM newHWM, string Create)
        {
            try
            {
                //see if they entered a survey date, if so, apply the survey_team_id
                if (newHWM.SURVEY_DATE != null)
                {
                    newHWM.SURVEY_TEAM_ID = newHWM.FLAG_TEAM_ID;
                }

                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource      = "HWMs/";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <HWM>(newHWM), ParameterType.RequestBody);

                string siteID     = newHWM.SITE_ID.ToString();
                HWM    createdHWM = serviceCaller.Execute <HWM>(request);

                //determine which button was clicked
                if (Create == "Submit & Add\r\nPeak Summary") //Submit & Add HWM
                {
                    return(RedirectToAction("CreatePeakSumForm", "PeakSummary", new { id = createdHWM.HWM_ID, FROM = "HWM" }));
                }
                else //Submit
                {
                    return(RedirectToAction("Details", new { id = createdHWM.HWM_ID }));
                }
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 5
0
        public ActionResult ObjPointCreate(OPModel newObjPt, string Create)
        {
            try
            {
                OBJECTIVE_POINT newOP = BuildOP(newObjPt);

                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource      = "/ObjectivePoints";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");

                //use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <OBJECTIVE_POINT>(newOP), ParameterType.RequestBody);
                OBJECTIVE_POINT createdOP = serviceCaller.Execute <OBJECTIVE_POINT>(request);

                //post ControlIdentifiers if some were chosen
                if (newObjPt.OPIdentifiers != null)
                {
                    if (newObjPt.OPIdentifiers.Count >= 1)
                    {
                        foreach (OP_CONTROL_IDENTIFIER opCI in newObjPt.OPIdentifiers)
                        {
                            //post each one for this OP
                            request          = new RestRequest(Method.POST);
                            request.Resource = "ObjectivePoints/{objectivePointId}/AddOPControls";
                            request.AddParameter("objectivePointId", createdOP.OBJECTIVE_POINT_ID, ParameterType.UrlSegment);
                            request.RequestFormat = DataFormat.Xml;
                            request.AddHeader("Content-Type", "application/xml");
                            serializer = new STNWebSerializer();
                            request.AddParameter("application/xml", serializer.Serialize <OP_CONTROL_IDENTIFIER>(opCI), ParameterType.RequestBody);
                            serviceCaller.Execute <OP_CONTROL_IDENTIFIER>(request);
                        }
                    }
                }
                string siteId = newObjPt.SITE_ID.ToString();
                //determine which submit button was selected
                if (Create == "Submit &\r\nAdd Another OP") //Submit & Add Another OP
                {
                    return(RedirectToAction("ObjPointCreate", "ObjPoints", new { siteID = siteId }));
                }
                else if (Create == "Submit &\r\nAdd Upload File")
                {
                    return(RedirectToAction("FileCreate", "Files", new { Id = createdOP.OBJECTIVE_POINT_ID, aPage = "OP" }));
                }
                else if (Create == "Submit &\r\nDeploy Sensor") // Submit & Deploy Sensor
                {
                    return(RedirectToAction("Create", "Instruments", new { siteID = siteId }));
                }
                else if (Create == "Submit\r\n& Add HWM") //Submit & Add HWM
                {
                    return(RedirectToAction("Create", "HWMs", new { siteID = siteId }));
                }
                else //just Submit
                {
                    return(RedirectToAction("Details", "Sites", new { id = siteId }));
                }
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 6
0
        public ActionResult ObjPointEdit(int id, OPModel anObjPtM)
        {
            try
            {
                OBJECTIVE_POINT editedOP = BuildOP(anObjPtM);

                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);

                request.Resource      = "/ObjectivePoints/{entityId}";
                request.RequestFormat = DataFormat.Xml;
                request.AddParameter("entityId", id, ParameterType.UrlSegment);
                request.AddHeader("X-HTTP-Method-Override", "PUT");
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <OBJECTIVE_POINT>(editedOP), ParameterType.RequestBody);
                OBJECTIVE_POINT anObjPoint = serviceCaller.Execute <OBJECTIVE_POINT>(request);

                if (anObjPtM.OPIdentifiers != null)
                {
                    foreach (OP_CONTROL_IDENTIFIER opi in anObjPtM.OPIdentifiers)
                    {
                        //if it has an id, it's a PUT
                        if (opi.OP_CONTROL_IDENTIFIER_ID == 0)
                        {
                            //POST it
                            request          = new RestRequest(Method.POST);
                            request.Resource = "ObjectivePoints/{objectivePointId}/AddOPControls";
                            request.AddParameter("objectivePointId", editedOP.OBJECTIVE_POINT_ID, ParameterType.UrlSegment);
                            request.RequestFormat = DataFormat.Xml;
                            request.AddHeader("Content-Type", "application/xml");
                            serializer = new STNWebSerializer();
                            request.AddParameter("application/xml", serializer.Serialize <OP_CONTROL_IDENTIFIER>(opi), ParameterType.RequestBody);
                            serviceCaller.Execute <OP_CONTROL_IDENTIFIER>(request);
                        }
                        else
                        {
                            //PUT it
                            opi.OBJECTIVE_POINT_ID = editedOP.OBJECTIVE_POINT_ID;
                            request               = new RestRequest(Method.POST);
                            request.Resource      = "/OPControlIdentifiers/{entityId}";
                            request.RequestFormat = DataFormat.Xml;
                            request.AddParameter("entityId", opi.OP_CONTROL_IDENTIFIER_ID, ParameterType.UrlSegment);
                            request.AddHeader("X-HTTP-Method-Override", "PUT");
                            request.AddHeader("Content-Type", "application/xml");
                            //Use extended serializer
                            serializer = new STNWebSerializer();
                            request.AddParameter("application/xml", serializer.Serialize <OP_CONTROL_IDENTIFIER>(opi), ParameterType.RequestBody);
                            serviceCaller.Execute <OP_CONTROL_IDENTIFIER>(request);
                        }
                    }
//                    List<decimal> identifiersExisted = anObjPtM.IdentifiersIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToDecimal(x)).ToList();
                }

                //remove these
                if (!string.IsNullOrEmpty(anObjPtM.IdentifiersToRemove))
                {
                    List <decimal> identifiersRemoving = anObjPtM.IdentifiersToRemove.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToDecimal(x)).ToList();
                    foreach (decimal identifierID in identifiersRemoving)
                    {
                        //DELETE
                        request          = new RestRequest(Method.POST);
                        request.Resource = "/OPControlIdentifiers/{entityId}";
                        request.AddParameter("entityId", identifierID, ParameterType.UrlSegment);
                        request.AddHeader("X-HTTP-Method-Override", "DELETE");
                        request.AddHeader("Content-Type", "application/xml");

                        serviceCaller.Execute <OP_CONTROL_IDENTIFIER>(request);
                    }
                }

                return(RedirectToAction("ObjPointDetailsPV", new { id = editedOP.OBJECTIVE_POINT_ID }));
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 7
0
        public ActionResult CreateCollectTeam(FormCollection thisFC)
        {
            try
            {
                //create collectTeam
                COLLECT_TEAM aColTeam = new COLLECT_TEAM();
                aColTeam.DESCRIPTION = thisFC["TeamName"];

                //make sure there's a description - was getting empty ones due to log off issue

                if (string.IsNullOrEmpty(aColTeam.DESCRIPTION))
                {
                    aColTeam.DESCRIPTION = "Left Empty";
                }

                //create the collection team first
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource      = "/CollectionTeams";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <COLLECT_TEAM>(aColTeam), ParameterType.RequestBody);
                COLLECT_TEAM newTeam = serviceCaller.Execute <COLLECT_TEAM>(request);

                Session["TeamId"]   = newTeam.COLLECT_TEAM_ID;
                Session["TeamName"] = newTeam.DESCRIPTION;

                //then add the members.
                MEMBER        member1      = new MEMBER();
                MEMBER        member2      = new MEMBER();
                List <MEMBER> theseMembers = new List <MEMBER>();

                string m1Username = thisFC["thisUserName"];
                string m2Username = thisFC["WhoRUwith"];

                if (m1Username != "")
                {
                    request             = new RestRequest();
                    request.Resource    = "/Members?username={userName}";
                    request.RootElement = "MEMBER";
                    request.AddParameter("userName", m1Username, ParameterType.UrlSegment);
                    member1 = serviceCaller.Execute <MEMBER>(request);
                    theseMembers.Add(member1);
                }

                if (m2Username != "")
                {
                    request             = new RestRequest();
                    request.Resource    = "/Members?username={userName}";
                    request.RootElement = "MEMBER";
                    request.AddParameter("userName", m2Username, ParameterType.UrlSegment);
                    member2 = serviceCaller.Execute <MEMBER>(request);
                    theseMembers.Add(member2);
                }

                List <MEMBER> listMembers = new List <MEMBER>();

                foreach (MEMBER aMember in theseMembers)
                {
                    request          = new RestRequest();
                    request.Method   = Method.POST;
                    request.Resource = "/CollectionTeams/{teamId}/AddMember";
                    request.AddParameter("teamId", newTeam.COLLECT_TEAM_ID, ParameterType.UrlSegment);
                    request.RequestFormat = DataFormat.Xml;
                    request.AddHeader("Content-Type", "application/xml");
                    request.AddParameter("application/xml", request.XmlSerializer.Serialize(aMember), ParameterType.RequestBody);
                    listMembers = serviceCaller.Execute <List <MEMBER> >(request);
                }
                string rdURL = thisFC["RedirectURL"];

                return(RedirectToAction("Index", new { returnUrl = rdURL }));
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 8
0
        public ActionResult CreatePeakSumForm(PeakSummaryModel peak)
        {
            try
            {
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;

                //build the PEAKSUMMARY object from Peak Model
                PEAK_SUMMARY newPeakSum = new PEAK_SUMMARY();

                newPeakSum.MEMBER_ID = GetMember(User.Identity.Name).MEMBER_ID;

                string date = peak.PeakDate; // mm/dd/yyyy
                string time = peak.PeakTime; // hh:mm PM

                string datetime = date + " " + time;
                newPeakSum.PEAK_DATE = DateTime.Parse(datetime, System.Globalization.CultureInfo.InvariantCulture);

                newPeakSum.TIME_ZONE = peak.TimeZone;

                if (newPeakSum.TIME_ZONE != "UTC")
                {
                    newPeakSum.TIME_ZONE = "UTC";
                    newPeakSum.PEAK_DATE = newPeakSum.PEAK_DATE.Value.ToUniversalTime();
                }

                newPeakSum.IS_PEAK_ESTIMATED      = peak.DateEstimated;
                newPeakSum.IS_PEAK_TIME_ESTIMATED = peak.TimeEstimated;

                newPeakSum.PEAK_STAGE = peak.PeakStage;
                newPeakSum.IS_PEAK_STAGE_ESTIMATED = peak.StageEstimated;
                newPeakSum.VDATUM_ID                   = peak.VdatumID;
                newPeakSum.HEIGHT_ABOVE_GND            = peak.HeightAboveGround;
                newPeakSum.IS_HAG_ESTIMATED            = peak.HAGEstimated;
                newPeakSum.PEAK_DISCHARGE              = peak.PeakDischarge;
                newPeakSum.IS_PEAK_DISCHARGE_ESTIMATED = peak.DischargeEstimated;

                //post the new Peak Summary
                var request = new RestRequest(Method.POST);
                request.Resource      = "/PeakSummaries";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <PEAK_SUMMARY>(newPeakSum), ParameterType.RequestBody);
                PEAK_SUMMARY createdPeakSum = serviceCaller.Execute <PEAK_SUMMARY>(request);

                //check to see if this is a Peak summary for a File or for a HWM
                //put peakSummary_id into File.PEakSummaryID or HWM.PeakSummaryID
                var FROM = peak.From;
                if (FROM == "File")
                {
                    //use id to get the file, then datafile to assign peak summary id to field
                    FILE aFile = GetFile(peak.objID);

                    DATA_FILE thisDF = GetDataFile(aFile.DATA_FILE_ID);

                    thisDF.PEAK_SUMMARY_ID = createdPeakSum.PEAK_SUMMARY_ID;

                    //now PUT this back to the service
                    request               = new RestRequest(Method.POST);
                    request.Resource      = "DataFiles/{entityId}";
                    request.RequestFormat = DataFormat.Xml;
                    request.AddParameter("entityId", thisDF.DATA_FILE_ID, ParameterType.UrlSegment);
                    request.AddHeader("X-HTTP-Method-Override", "PUT");
                    request.AddHeader("Content-Type", "application/xml");
                    //Use extended serializer
                    serializer = new STNWebSerializer();
                    request.AddParameter("application/xml", serializer.Serialize <DATA_FILE>(thisDF), ParameterType.RequestBody);
                    serviceCaller.Execute <DATA_FILE>(request);

                    //return to filedetails page using fileid to refresh
                    return(RedirectToAction("FileDetails", "Files", new { id = peak.objID }));
                }
                else //(FROM == "HWM")
                {
                    //use id to get HWM file to assign peak summary id to field
                    request             = new RestRequest();
                    request.Resource    = "HWMs/{entityId}";
                    request.RootElement = "HWM";
                    request.AddParameter("entityId", peak.objID, ParameterType.UrlSegment);
                    HWM aHWM = serviceCaller.Execute <HWM>(request);

                    aHWM.PEAK_SUMMARY_ID = createdPeakSum.PEAK_SUMMARY_ID;

                    //now PUT this back to the service
                    request               = new RestRequest(Method.POST);
                    request.Resource      = "HWMs/{entityId}";
                    request.RequestFormat = DataFormat.Xml;
                    request.AddParameter("entityId", aHWM.HWM_ID, ParameterType.UrlSegment);
                    request.AddHeader("X-HTTP-Method-Override", "PUT");
                    request.AddHeader("Content-Type", "application/xml");
                    //Use extended serializer
                    serializer = new STNWebSerializer();
                    request.AddParameter("application/xml", serializer.Serialize <HWM>(aHWM), ParameterType.RequestBody);
                    serviceCaller.Execute <HWM>(request);

                    //return to hwmdetails page using hwmid to refresh
                    return(RedirectToAction("Details", "HWMs", new { id = peak.objID }));
                }
            }
            catch (Exception e)
            {
                return(View("../Shared/Error", e));
            }
        }
Exemplo n.º 9
0
        public ActionResult EditPeakSum(int id, PeakSummaryModel PeakModel)
        {
            try
            {
                PEAK_SUMMARY     editSummary   = new PEAK_SUMMARY();
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;

                //store formcollection items
                editSummary.PEAK_SUMMARY_ID = PeakModel.peakID;
                editSummary.MEMBER_ID       = PeakModel.memberID;
                string date = PeakModel.PeakDate; // mm/dd/yyyy
                string time = PeakModel.PeakTime; // hh:mm PM

                string datetime = date + " " + time;
                editSummary.PEAK_DATE                   = DateTime.Parse(datetime, System.Globalization.CultureInfo.InvariantCulture);
                editSummary.IS_PEAK_ESTIMATED           = PeakModel.DateEstimated;
                editSummary.IS_PEAK_TIME_ESTIMATED      = PeakModel.TimeEstimated;
                editSummary.PEAK_STAGE                  = PeakModel.PeakStage;
                editSummary.IS_PEAK_STAGE_ESTIMATED     = PeakModel.StageEstimated;
                editSummary.PEAK_DISCHARGE              = PeakModel.PeakDischarge;
                editSummary.IS_PEAK_DISCHARGE_ESTIMATED = PeakModel.DischargeEstimated;
                editSummary.VDATUM_ID                   = PeakModel.VdatumID;
                editSummary.HEIGHT_ABOVE_GND            = PeakModel.HeightAboveGround;
                editSummary.IS_HAG_ESTIMATED            = PeakModel.HAGEstimated;
                editSummary.TIME_ZONE                   = PeakModel.TimeZone;

                //make sure it's UTC
                if (editSummary.TIME_ZONE != "UTC")
                {
                    editSummary.TIME_ZONE = "UTC";
                    editSummary.PEAK_DATE = editSummary.PEAK_DATE.Value.ToUniversalTime();
                }

                var request = new RestRequest(Method.POST);
                request.Resource      = "/PeakSummaries/{entityId}";
                request.RequestFormat = DataFormat.Xml;
                request.AddParameter("entityId", id, ParameterType.UrlSegment);
                request.AddHeader("X-HTTP-Method-Override", "PUT");
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <PEAK_SUMMARY>(editSummary), ParameterType.RequestBody);
                PEAK_SUMMARY updatedPeak = serviceCaller.Execute <PEAK_SUMMARY>(request);

                //store for details view
                request             = new RestRequest();
                request.Resource    = "/Members/{entityId}";
                request.RootElement = "MEMBER";
                request.AddParameter("entityId", PeakModel.memberID, ParameterType.UrlSegment);
                ViewData["MemberUsername"] = serviceCaller.Execute <MEMBER>(request).USERNAME;

                request             = new RestRequest();
                request.Resource    = "/VerticalDatums/{entityId}";
                request.RootElement = "VERTICAL_DATUMS";
                request.AddParameter("entityId", PeakModel.VdatumID, ParameterType.UrlSegment);
                ViewData["VDType"] = serviceCaller.Execute <VERTICAL_DATUMS>(request).DATUM_NAME;

                return(PartialView("PeakSumDetailsPV", updatedPeak));
            }
            catch (Exception e)
            {
                return(PartialView("../Shared/Error", e));
            }
        }
Exemplo n.º 10
0
        public PartialViewResult Edit(int id, HWM aHWM)
        {
            try
            {
                if (aHWM.SURVEY_DATE != null)
                {
                    //they added a date, or there was one there already
                    if (aHWM.SURVEY_TEAM_ID == null)
                    {
                        //there's no survey team stored, so they are just now surveying it
                        aHWM.SURVEY_TEAM_ID = Convert.ToDecimal(Request.Form["UseThisSurveyID"]);
                    }
                }
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest(Method.POST);

                request.Resource      = "HWMs/{entityId}";
                request.RequestFormat = DataFormat.Xml;
                request.AddParameter("entityId", id, ParameterType.UrlSegment);
                request.AddHeader("X-HTTP-Method-Override", "PUT");
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                STNWebSerializer serializer = new STNWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize <HWM>(aHWM), ParameterType.RequestBody);
                serviceCaller.Execute <HWM>(request);

                //**store info in ViewData for return to Partial View**//
                //get site name and number
                request             = new RestRequest();
                request.Resource    = "Sites/{entityId}";
                request.RootElement = "SITE";
                request.AddParameter("entityId", aHWM.SITE_ID, ParameterType.UrlSegment);
                SITE aSite = serviceCaller.Execute <SITE>(request);
                ViewData["aSite"]  = aSite;
                ViewData["SiteNo"] = aSite.SITE_NO;

                //get event
                request             = new RestRequest();
                request.Resource    = "/Events/{entityId}";
                request.RootElement = "EVENT";
                request.AddParameter("entityId", aHWM.EVENT_ID, ParameterType.UrlSegment);
                EVENT thisEvent = serviceCaller.Execute <EVENT>(request);
                if (thisEvent != null)
                {
                    ViewData["Event"] = thisEvent.EVENT_NAME;
                }

                //get HWM Type
                request             = new RestRequest();
                request.Resource    = "/HWMTypes/{entityId}";
                request.RootElement = "HWM_TYPES";
                request.AddParameter("entityId", aHWM.HWM_TYPE_ID, ParameterType.UrlSegment);
                HWM_TYPES thisHWMType = serviceCaller.Execute <HWM_TYPES>(request);
                if (thisHWMType != null)
                {
                    ViewData["HWMType"] = thisHWMType.HWM_TYPE;
                }

                //get HWM Quality
                request             = new RestRequest();
                request.Resource    = "/HWMQualities/{entityId}";
                request.RootElement = "HWM_QUALITIES";
                request.AddParameter("entityId", aHWM.HWM_QUALITY_ID, ParameterType.UrlSegment);
                HWM_QUALITIES thisHWMQual = serviceCaller.Execute <HWM_QUALITIES>(request);
                if (thisHWMQual != null)
                {
                    ViewData["HWMQual"] = thisHWMQual.HWM_QUALITY;
                }

                //build hwm quality field based on Environment and quality
                if (aHWM.HWM_ENVIRONMENT == "Coastal")
                {
                    switch (Convert.ToInt32(aHWM.HWM_QUALITY_ID))
                    {
                    case 1:     //Excellent
                        ViewData["QualValue"] = "(+/- 0.05)"; break;

                    case 2:     //Good
                        ViewData["QualValue"] = "(+/- 0.1)"; break;

                    case 3:     //Fair
                        ViewData["QualValue"] = "(+/- 0.2)"; break;

                    case 4:     //Poor
                        ViewData["QualValue"] = "(+/- 0.4)"; break;

                    default:     //VP
                        ViewData["QualValue"] = "(>0.40)"; break;
                    }
                }
                else // "riverine"
                {
                    switch (Convert.ToInt32(aHWM.HWM_QUALITY_ID))
                    {
                    case 1:     //Excellent
                        ViewData["QualValue"] = "(+/- 0.02)"; break;

                    case 2:     //Good
                        ViewData["QualValue"] = "(+/- 0.05)"; break;

                    case 3:     //Fair
                        ViewData["QualValue"] = "(+/- 0.1)"; break;

                    case 4:     //Poor
                        ViewData["QualValue"] = "(+/- 0.2)"; break;

                    default:     //VP
                        ViewData["QualValue"] = "(>0.20)"; break;
                    }
                }

                //get FlagTeam
                request             = new RestRequest();
                request.Resource    = "/CollectionTeams/{entityId}";
                request.RootElement = "COLLECT_TEAM";
                request.AddParameter("entityId", aHWM.FLAG_TEAM_ID, ParameterType.UrlSegment);
                COLLECT_TEAM thisCollTm = serviceCaller.Execute <COLLECT_TEAM>(request);
                if (thisCollTm != null)
                {
                    ViewData["FlagTeam"] = thisCollTm.DESCRIPTION;
                }

                if (aHWM.SURVEY_TEAM_ID != null)
                {
                    //get surveyTeam
                    request             = new RestRequest();
                    request.Resource    = "/CollectionTeams/{entityId}";
                    request.RootElement = "COLLECT_TEAM";
                    request.AddParameter("entityId", aHWM.SURVEY_TEAM_ID, ParameterType.UrlSegment);
                    COLLECT_TEAM surveyTeam = serviceCaller.Execute <COLLECT_TEAM>(request);
                    if (surveyTeam != null)
                    {
                        ViewData["SurveyTeam"] = surveyTeam.DESCRIPTION;
                    }
                }

                if (thisCollTm != null)
                {
                    ViewData["FlagTeam"] = thisCollTm.DESCRIPTION;
                }


                //get collectionMethod
                request             = new RestRequest();
                request.Resource    = "/VerticalMethods/{entityId}";
                request.RootElement = "VERTICAL_COLLECT_METHODS";
                request.AddParameter("entityId", aHWM.VCOLLECT_METHOD_ID, ParameterType.UrlSegment);
                VERTICAL_COLLECT_METHODS thisVCollMtd = serviceCaller.Execute <VERTICAL_COLLECT_METHODS>(request);
                if (thisVCollMtd != null)
                {
                    ViewData["VCollectMethod"] = thisVCollMtd.VCOLLECT_METHOD;
                }

                //Get Vertical Datum
                request             = new RestRequest();
                request.Resource    = "/VerticalDatums/{entityId}";
                request.RootElement = "VERTICAL_DATUMS";
                request.AddParameter("entityId", aHWM.VDATUM_ID, ParameterType.UrlSegment);
                VERTICAL_DATUMS thisVD = serviceCaller.Execute <VERTICAL_DATUMS>(request);
                if (thisVD != null)
                {
                    ViewData["VerticalDatum"] = thisVD.DATUM_NAME;
                }

                //Get marker
                request             = new RestRequest();
                request.Resource    = "/Markers/{entityId}";
                request.RootElement = "MARKER";
                request.AddParameter("entityId", aHWM.MARKER_ID, ParameterType.UrlSegment);
                MARKER thisMarker = serviceCaller.Execute <MARKER>(request);
                if (thisMarker != null)
                {
                    ViewData["MarkerID"] = thisMarker.MARKER1;
                }

                //get Horizontal Collection Methods
                request             = new RestRequest();
                request.Resource    = "/HorizontalMethods/{entityId}";
                request.RootElement = "HORIZONTAL_COLLECT_METHODS";
                request.AddParameter("entityId", aHWM.HCOLLECT_METHOD_ID, ParameterType.UrlSegment);
                HORIZONTAL_COLLECT_METHODS thisHcoll = serviceCaller.Execute <HORIZONTAL_COLLECT_METHODS>(request);
                if (thisHcoll != null)
                {
                    ViewData["HCollectMethod"] = thisHcoll.HCOLLECT_METHOD;
                }

                return(PartialView("HWMDetailsPV", aHWM));
            }
            catch (Exception e)
            {
                return(PartialView("../Shared/Error", e));
            }
        }