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

                climateSiteService.Query = climateSiteService.FillQuery(typeof(ClimateSite), lang, 0, 1, "", "", extra);

                if (climateSiteService.Query.Extra == "A")
                {
                    ClimateSiteExtraA climateSiteExtraA = new ClimateSiteExtraA();
                    climateSiteExtraA = climateSiteService.GetClimateSiteExtraAWithClimateSiteID(ClimateSiteID);

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

                    return(Ok(climateSiteExtraA));
                }
                else if (climateSiteService.Query.Extra == "B")
                {
                    ClimateSiteExtraB climateSiteExtraB = new ClimateSiteExtraB();
                    climateSiteExtraB = climateSiteService.GetClimateSiteExtraBWithClimateSiteID(ClimateSiteID);

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

                    return(Ok(climateSiteExtraB));
                }
                else
                {
                    ClimateSite climateSite = new ClimateSite();
                    climateSite = climateSiteService.GetClimateSiteWithClimateSiteID(ClimateSiteID);

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

                    return(Ok(climateSite));
                }
            }
        }
 public ClimateSiteTest()
 {
     climateSite       = new ClimateSite();
     climateSiteExtraA = new ClimateSiteExtraA();
     climateSiteExtraB = new ClimateSiteExtraB();
 }