public IHttpActionResult GetInfrastructureLanguageWithID([FromUri] int InfrastructureLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { InfrastructureLanguageService infrastructureLanguageService = new InfrastructureLanguageService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguage), lang, 0, 1, "", "", extra); if (infrastructureLanguageService.Query.Extra == "A") { InfrastructureLanguageExtraA infrastructureLanguageExtraA = new InfrastructureLanguageExtraA(); infrastructureLanguageExtraA = infrastructureLanguageService.GetInfrastructureLanguageExtraAWithInfrastructureLanguageID(InfrastructureLanguageID); if (infrastructureLanguageExtraA == null) { return(NotFound()); } return(Ok(infrastructureLanguageExtraA)); } else if (infrastructureLanguageService.Query.Extra == "B") { InfrastructureLanguageExtraB infrastructureLanguageExtraB = new InfrastructureLanguageExtraB(); infrastructureLanguageExtraB = infrastructureLanguageService.GetInfrastructureLanguageExtraBWithInfrastructureLanguageID(InfrastructureLanguageID); if (infrastructureLanguageExtraB == null) { return(NotFound()); } return(Ok(infrastructureLanguageExtraB)); } else { InfrastructureLanguage infrastructureLanguage = new InfrastructureLanguage(); infrastructureLanguage = infrastructureLanguageService.GetInfrastructureLanguageWithInfrastructureLanguageID(InfrastructureLanguageID); if (infrastructureLanguage == null) { return(NotFound()); } return(Ok(infrastructureLanguage)); } } }
public void GetInfrastructureLanguageList_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" }) { InfrastructureLanguageService infrastructureLanguageService = new InfrastructureLanguageService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguage), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "InfrastructureLanguageID,GT,2|InfrastructureLanguageID,LT,5", extra); List <InfrastructureLanguage> infrastructureLanguageDirectQueryList = new List <InfrastructureLanguage>(); infrastructureLanguageDirectQueryList = (from c in dbTestDB.InfrastructureLanguages select c).Where(c => c.InfrastructureLanguageID > 2 && c.InfrastructureLanguageID < 5).ToList(); if (string.IsNullOrWhiteSpace(extra)) { List <InfrastructureLanguage> infrastructureLanguageList = new List <InfrastructureLanguage>(); infrastructureLanguageList = infrastructureLanguageService.GetInfrastructureLanguageList().ToList(); CheckInfrastructureLanguageFields(infrastructureLanguageList); Assert.AreEqual(infrastructureLanguageDirectQueryList[0].InfrastructureLanguageID, infrastructureLanguageList[0].InfrastructureLanguageID); } else { //Assert.AreEqual(true, false); } } } } }
public IHttpActionResult GetInfrastructureLanguageList([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)) { InfrastructureLanguageService infrastructureLanguageService = new InfrastructureLanguageService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguageExtraA), lang, skip, take, asc, desc, where, extra); if (infrastructureLanguageService.Query.HasErrors) { return(Ok(new List <InfrastructureLanguageExtraA>() { new InfrastructureLanguageExtraA() { HasErrors = infrastructureLanguageService.Query.HasErrors, ValidationResults = infrastructureLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(infrastructureLanguageService.GetInfrastructureLanguageExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguageExtraB), lang, skip, take, asc, desc, where, extra); if (infrastructureLanguageService.Query.HasErrors) { return(Ok(new List <InfrastructureLanguageExtraB>() { new InfrastructureLanguageExtraB() { HasErrors = infrastructureLanguageService.Query.HasErrors, ValidationResults = infrastructureLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(infrastructureLanguageService.GetInfrastructureLanguageExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { infrastructureLanguageService.Query = infrastructureLanguageService.FillQuery(typeof(InfrastructureLanguage), lang, skip, take, asc, desc, where, extra); if (infrastructureLanguageService.Query.HasErrors) { return(Ok(new List <InfrastructureLanguage>() { new InfrastructureLanguage() { HasErrors = infrastructureLanguageService.Query.HasErrors, ValidationResults = infrastructureLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(infrastructureLanguageService.GetInfrastructureLanguageList().ToList())); } } } }