public IHttpActionResult GetInfrastructureLanguageWithID([FromUri] int InfrastructureLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                InfrastructureLanguageService infrastructureLanguageService = new InfrastructureLanguageService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguage), lang, 0, 1, "", "", extra);

                if (infrastructureLanguageService.Query.Extra == "A")
                {
                    InfrastructureLanguageExtraA infrastructureLanguageExtraA = new InfrastructureLanguageExtraA();
                    infrastructureLanguageExtraA = infrastructureLanguageService.GetInfrastructureLanguageExtraAWithInfrastructureLanguageID(InfrastructureLanguageID);

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

                    return(Ok(infrastructureLanguageExtraA));
                }
                else if (infrastructureLanguageService.Query.Extra == "B")
                {
                    InfrastructureLanguageExtraB infrastructureLanguageExtraB = new InfrastructureLanguageExtraB();
                    infrastructureLanguageExtraB = infrastructureLanguageService.GetInfrastructureLanguageExtraBWithInfrastructureLanguageID(InfrastructureLanguageID);

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

                    return(Ok(infrastructureLanguageExtraB));
                }
                else
                {
                    InfrastructureLanguage infrastructureLanguage = new InfrastructureLanguage();
                    infrastructureLanguage = infrastructureLanguageService.GetInfrastructureLanguageWithInfrastructureLanguageID(InfrastructureLanguageID);

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

                    return(Ok(infrastructureLanguage));
                }
            }
        }
Esempio n. 2
0
        public void GetInfrastructureLanguageWithInfrastructureLanguageID__infrastructureLanguage_InfrastructureLanguageID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    InfrastructureLanguageService infrastructureLanguageService = new InfrastructureLanguageService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    InfrastructureLanguage infrastructureLanguage = (from c in dbTestDB.InfrastructureLanguages select c).FirstOrDefault();
                    Assert.IsNotNull(infrastructureLanguage);

                    foreach (string extra in new List <string>()
                    {
                        null, "A", "B", "C", "D", "E"
                    })
                    {
                        infrastructureLanguageService.Query.Extra = extra;

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            InfrastructureLanguage infrastructureLanguageRet = infrastructureLanguageService.GetInfrastructureLanguageWithInfrastructureLanguageID(infrastructureLanguage.InfrastructureLanguageID);
                            CheckInfrastructureLanguageFields(new List <InfrastructureLanguage>()
                            {
                                infrastructureLanguageRet
                            });
                            Assert.AreEqual(infrastructureLanguage.InfrastructureLanguageID, infrastructureLanguageRet.InfrastructureLanguageID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }