Exemplo n.º 1
0
        public IHttpActionResult GetHydrometricSiteWithID([FromUri] int HydrometricSiteID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                HydrometricSiteService hydrometricSiteService = new HydrometricSiteService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                hydrometricSiteService.Query = hydrometricSiteService.FillQuery(typeof(HydrometricSite), lang, 0, 1, "", "", extra);

                if (hydrometricSiteService.Query.Extra == "A")
                {
                    HydrometricSiteExtraA hydrometricSiteExtraA = new HydrometricSiteExtraA();
                    hydrometricSiteExtraA = hydrometricSiteService.GetHydrometricSiteExtraAWithHydrometricSiteID(HydrometricSiteID);

                    if (hydrometricSiteExtraA == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(hydrometricSiteExtraA));
                }
                else if (hydrometricSiteService.Query.Extra == "B")
                {
                    HydrometricSiteExtraB hydrometricSiteExtraB = new HydrometricSiteExtraB();
                    hydrometricSiteExtraB = hydrometricSiteService.GetHydrometricSiteExtraBWithHydrometricSiteID(HydrometricSiteID);

                    if (hydrometricSiteExtraB == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(hydrometricSiteExtraB));
                }
                else
                {
                    HydrometricSite hydrometricSite = new HydrometricSite();
                    hydrometricSite = hydrometricSiteService.GetHydrometricSiteWithHydrometricSiteID(HydrometricSiteID);

                    if (hydrometricSite == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(hydrometricSite));
                }
            }
        }
Exemplo n.º 2
0
 public HydrometricSiteTest()
 {
     hydrometricSite       = new HydrometricSite();
     hydrometricSiteExtraA = new HydrometricSiteExtraA();
     hydrometricSiteExtraB = new HydrometricSiteExtraB();
 }