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

                appTaskLanguageService.Query = appTaskLanguageService.FillQuery(typeof(AppTaskLanguage), lang, 0, 1, "", "", extra);

                if (appTaskLanguageService.Query.Extra == "A")
                {
                    AppTaskLanguageExtraA appTaskLanguageExtraA = new AppTaskLanguageExtraA();
                    appTaskLanguageExtraA = appTaskLanguageService.GetAppTaskLanguageExtraAWithAppTaskLanguageID(AppTaskLanguageID);

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

                    return(Ok(appTaskLanguageExtraA));
                }
                else if (appTaskLanguageService.Query.Extra == "B")
                {
                    AppTaskLanguageExtraB appTaskLanguageExtraB = new AppTaskLanguageExtraB();
                    appTaskLanguageExtraB = appTaskLanguageService.GetAppTaskLanguageExtraBWithAppTaskLanguageID(AppTaskLanguageID);

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

                    return(Ok(appTaskLanguageExtraB));
                }
                else
                {
                    AppTaskLanguage appTaskLanguage = new AppTaskLanguage();
                    appTaskLanguage = appTaskLanguageService.GetAppTaskLanguageWithAppTaskLanguageID(AppTaskLanguageID);

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

                    return(Ok(appTaskLanguage));
                }
            }
        }
Exemplo n.º 2
0
        public void GetAppTaskLanguageWithAppTaskLanguageID__appTaskLanguage_AppTaskLanguageID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    AppTaskLanguageService appTaskLanguageService = new AppTaskLanguageService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    AppTaskLanguage appTaskLanguage = (from c in dbTestDB.AppTaskLanguages select c).FirstOrDefault();
                    Assert.IsNotNull(appTaskLanguage);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            AppTaskLanguage appTaskLanguageRet = appTaskLanguageService.GetAppTaskLanguageWithAppTaskLanguageID(appTaskLanguage.AppTaskLanguageID);
                            CheckAppTaskLanguageFields(new List <AppTaskLanguage>()
                            {
                                appTaskLanguageRet
                            });
                            Assert.AreEqual(appTaskLanguage.AppTaskLanguageID, appTaskLanguageRet.AppTaskLanguageID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }