public IHttpActionResult GetTVFileLanguageWithID([FromUri] int TVFileLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { TVFileLanguageService tvFileLanguageService = new TVFileLanguageService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguage), lang, 0, 1, "", "", extra); if (tvFileLanguageService.Query.Extra == "A") { TVFileLanguageExtraA tvFileLanguageExtraA = new TVFileLanguageExtraA(); tvFileLanguageExtraA = tvFileLanguageService.GetTVFileLanguageExtraAWithTVFileLanguageID(TVFileLanguageID); if (tvFileLanguageExtraA == null) { return(NotFound()); } return(Ok(tvFileLanguageExtraA)); } else if (tvFileLanguageService.Query.Extra == "B") { TVFileLanguageExtraB tvFileLanguageExtraB = new TVFileLanguageExtraB(); tvFileLanguageExtraB = tvFileLanguageService.GetTVFileLanguageExtraBWithTVFileLanguageID(TVFileLanguageID); if (tvFileLanguageExtraB == null) { return(NotFound()); } return(Ok(tvFileLanguageExtraB)); } else { TVFileLanguage tvFileLanguage = new TVFileLanguage(); tvFileLanguage = tvFileLanguageService.GetTVFileLanguageWithTVFileLanguageID(TVFileLanguageID); if (tvFileLanguage == null) { return(NotFound()); } return(Ok(tvFileLanguage)); } } }
public void GetTVFileLanguageList_2Where_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { TVFileLanguageService tvFileLanguageService = new TVFileLanguageService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguage), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "TVFileLanguageID,GT,2|TVFileLanguageID,LT,5", extra); List <TVFileLanguage> tvFileLanguageDirectQueryList = new List <TVFileLanguage>(); tvFileLanguageDirectQueryList = (from c in dbTestDB.TVFileLanguages select c).Where(c => c.TVFileLanguageID > 2 && c.TVFileLanguageID < 5).ToList(); if (string.IsNullOrWhiteSpace(extra)) { List <TVFileLanguage> tvFileLanguageList = new List <TVFileLanguage>(); tvFileLanguageList = tvFileLanguageService.GetTVFileLanguageList().ToList(); CheckTVFileLanguageFields(tvFileLanguageList); Assert.AreEqual(tvFileLanguageDirectQueryList[0].TVFileLanguageID, tvFileLanguageList[0].TVFileLanguageID); } else { //Assert.AreEqual(true, false); } } } } }
public IHttpActionResult GetTVFileLanguageList([FromUri] string lang = "en", [FromUri] int skip = 0, [FromUri] int take = 200, [FromUri] string asc = "", [FromUri] string desc = "", [FromUri] string where = "", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { TVFileLanguageService tvFileLanguageService = new TVFileLanguageService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguageExtraA), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguageExtraA>() { new TVFileLanguageExtraA() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguageExtraB), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguageExtraB>() { new TVFileLanguageExtraB() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguage), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguage>() { new TVFileLanguage() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageList().ToList())); } } } }