Пример #1
0
        public IHttpActionResult GetInfrastructureWithID([FromUri] int InfrastructureID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                InfrastructureService infrastructureService = new InfrastructureService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                infrastructureService.Query = infrastructureService.FillQuery(typeof(Infrastructure), lang, 0, 1, "", "", extra);

                if (infrastructureService.Query.Extra == "A")
                {
                    InfrastructureExtraA infrastructureExtraA = new InfrastructureExtraA();
                    infrastructureExtraA = infrastructureService.GetInfrastructureExtraAWithInfrastructureID(InfrastructureID);

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

                    return(Ok(infrastructureExtraA));
                }
                else if (infrastructureService.Query.Extra == "B")
                {
                    InfrastructureExtraB infrastructureExtraB = new InfrastructureExtraB();
                    infrastructureExtraB = infrastructureService.GetInfrastructureExtraBWithInfrastructureID(InfrastructureID);

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

                    return(Ok(infrastructureExtraB));
                }
                else
                {
                    Infrastructure infrastructure = new Infrastructure();
                    infrastructure = infrastructureService.GetInfrastructureWithInfrastructureID(InfrastructureID);

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

                    return(Ok(infrastructure));
                }
            }
        }
Пример #2
0
 public InfrastructureTest()
 {
     infrastructure       = new Infrastructure();
     infrastructureExtraA = new InfrastructureExtraA();
     infrastructureExtraB = new InfrastructureExtraB();
 }