예제 #1
0
        public IHttpActionResult GetVPScenarioLanguageWithID([FromUri] int VPScenarioLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                VPScenarioLanguageService vpScenarioLanguageService = new VPScenarioLanguageService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                vpScenarioLanguageService.Query = vpScenarioLanguageService.FillQuery(typeof(VPScenarioLanguage), lang, 0, 1, "", "", extra);

                if (vpScenarioLanguageService.Query.Extra == "A")
                {
                    VPScenarioLanguageExtraA vpScenarioLanguageExtraA = new VPScenarioLanguageExtraA();
                    vpScenarioLanguageExtraA = vpScenarioLanguageService.GetVPScenarioLanguageExtraAWithVPScenarioLanguageID(VPScenarioLanguageID);

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

                    return(Ok(vpScenarioLanguageExtraA));
                }
                else if (vpScenarioLanguageService.Query.Extra == "B")
                {
                    VPScenarioLanguageExtraB vpScenarioLanguageExtraB = new VPScenarioLanguageExtraB();
                    vpScenarioLanguageExtraB = vpScenarioLanguageService.GetVPScenarioLanguageExtraBWithVPScenarioLanguageID(VPScenarioLanguageID);

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

                    return(Ok(vpScenarioLanguageExtraB));
                }
                else
                {
                    VPScenarioLanguage vpScenarioLanguage = new VPScenarioLanguage();
                    vpScenarioLanguage = vpScenarioLanguageService.GetVPScenarioLanguageWithVPScenarioLanguageID(VPScenarioLanguageID);

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

                    return(Ok(vpScenarioLanguage));
                }
            }
        }
        public void GetVPScenarioLanguageWithVPScenarioLanguageID__vpScenarioLanguage_VPScenarioLanguageID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    VPScenarioLanguageService vpScenarioLanguageService = new VPScenarioLanguageService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    VPScenarioLanguage vpScenarioLanguage = (from c in dbTestDB.VPScenarioLanguages select c).FirstOrDefault();
                    Assert.IsNotNull(vpScenarioLanguage);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            VPScenarioLanguage vpScenarioLanguageRet = vpScenarioLanguageService.GetVPScenarioLanguageWithVPScenarioLanguageID(vpScenarioLanguage.VPScenarioLanguageID);
                            CheckVPScenarioLanguageFields(new List <VPScenarioLanguage>()
                            {
                                vpScenarioLanguageRet
                            });
                            Assert.AreEqual(vpScenarioLanguage.VPScenarioLanguageID, vpScenarioLanguageRet.VPScenarioLanguageID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }