public IHttpActionResult GetMWQMRunLanguageWithID([FromUri] int MWQMRunLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { MWQMRunLanguageService mwqmRunLanguageService = new MWQMRunLanguageService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); mwqmRunLanguageService.Query = mwqmRunLanguageService.FillQuery(typeof(MWQMRunLanguage), lang, 0, 1, "", "", extra); if (mwqmRunLanguageService.Query.Extra == "A") { MWQMRunLanguageExtraA mwqmRunLanguageExtraA = new MWQMRunLanguageExtraA(); mwqmRunLanguageExtraA = mwqmRunLanguageService.GetMWQMRunLanguageExtraAWithMWQMRunLanguageID(MWQMRunLanguageID); if (mwqmRunLanguageExtraA == null) { return(NotFound()); } return(Ok(mwqmRunLanguageExtraA)); } else if (mwqmRunLanguageService.Query.Extra == "B") { MWQMRunLanguageExtraB mwqmRunLanguageExtraB = new MWQMRunLanguageExtraB(); mwqmRunLanguageExtraB = mwqmRunLanguageService.GetMWQMRunLanguageExtraBWithMWQMRunLanguageID(MWQMRunLanguageID); if (mwqmRunLanguageExtraB == null) { return(NotFound()); } return(Ok(mwqmRunLanguageExtraB)); } else { MWQMRunLanguage mwqmRunLanguage = new MWQMRunLanguage(); mwqmRunLanguage = mwqmRunLanguageService.GetMWQMRunLanguageWithMWQMRunLanguageID(MWQMRunLanguageID); if (mwqmRunLanguage == null) { return(NotFound()); } return(Ok(mwqmRunLanguage)); } } }
public void GetMWQMRunLanguageWithMWQMRunLanguageID__mwqmRunLanguage_MWQMRunLanguageID__Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { MWQMRunLanguageService mwqmRunLanguageService = new MWQMRunLanguageService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); MWQMRunLanguage mwqmRunLanguage = (from c in dbTestDB.MWQMRunLanguages select c).FirstOrDefault(); Assert.IsNotNull(mwqmRunLanguage); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { mwqmRunLanguageService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { MWQMRunLanguage mwqmRunLanguageRet = mwqmRunLanguageService.GetMWQMRunLanguageWithMWQMRunLanguageID(mwqmRunLanguage.MWQMRunLanguageID); CheckMWQMRunLanguageFields(new List <MWQMRunLanguage>() { mwqmRunLanguageRet }); Assert.AreEqual(mwqmRunLanguage.MWQMRunLanguageID, mwqmRunLanguageRet.MWQMRunLanguageID); } else { //Assert.AreEqual(true, false); } } } } }