public IHttpActionResult GetSpillLanguageWithID([FromUri] int SpillLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SpillLanguageService spillLanguageService = new SpillLanguageService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); spillLanguageService.Query = spillLanguageService.FillQuery(typeof(SpillLanguage), lang, 0, 1, "", "", extra); if (spillLanguageService.Query.Extra == "A") { SpillLanguageExtraA spillLanguageExtraA = new SpillLanguageExtraA(); spillLanguageExtraA = spillLanguageService.GetSpillLanguageExtraAWithSpillLanguageID(SpillLanguageID); if (spillLanguageExtraA == null) { return(NotFound()); } return(Ok(spillLanguageExtraA)); } else if (spillLanguageService.Query.Extra == "B") { SpillLanguageExtraB spillLanguageExtraB = new SpillLanguageExtraB(); spillLanguageExtraB = spillLanguageService.GetSpillLanguageExtraBWithSpillLanguageID(SpillLanguageID); if (spillLanguageExtraB == null) { return(NotFound()); } return(Ok(spillLanguageExtraB)); } else { SpillLanguage spillLanguage = new SpillLanguage(); spillLanguage = spillLanguageService.GetSpillLanguageWithSpillLanguageID(SpillLanguageID); if (spillLanguage == null) { return(NotFound()); } return(Ok(spillLanguage)); } } }
public void GetSpillLanguageWithSpillLanguageID__spillLanguage_SpillLanguageID__Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { SpillLanguageService spillLanguageService = new SpillLanguageService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); SpillLanguage spillLanguage = (from c in dbTestDB.SpillLanguages select c).FirstOrDefault(); Assert.IsNotNull(spillLanguage); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { spillLanguageService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { SpillLanguage spillLanguageRet = spillLanguageService.GetSpillLanguageWithSpillLanguageID(spillLanguage.SpillLanguageID); CheckSpillLanguageFields(new List <SpillLanguage>() { spillLanguageRet }); Assert.AreEqual(spillLanguage.SpillLanguageID, spillLanguageRet.SpillLanguageID); } else { //Assert.AreEqual(true, false); } } } } }