public IHttpActionResult GetEmailDistributionListLanguageWithID([FromUri] int EmailDistributionListLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { EmailDistributionListLanguageService emailDistributionListLanguageService = new EmailDistributionListLanguageService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); emailDistributionListLanguageService.Query = emailDistributionListLanguageService.FillQuery(typeof(EmailDistributionListLanguage), lang, 0, 1, "", "", extra); if (emailDistributionListLanguageService.Query.Extra == "A") { EmailDistributionListLanguageExtraA emailDistributionListLanguageExtraA = new EmailDistributionListLanguageExtraA(); emailDistributionListLanguageExtraA = emailDistributionListLanguageService.GetEmailDistributionListLanguageExtraAWithEmailDistributionListLanguageID(EmailDistributionListLanguageID); if (emailDistributionListLanguageExtraA == null) { return(NotFound()); } return(Ok(emailDistributionListLanguageExtraA)); } else if (emailDistributionListLanguageService.Query.Extra == "B") { EmailDistributionListLanguageExtraB emailDistributionListLanguageExtraB = new EmailDistributionListLanguageExtraB(); emailDistributionListLanguageExtraB = emailDistributionListLanguageService.GetEmailDistributionListLanguageExtraBWithEmailDistributionListLanguageID(EmailDistributionListLanguageID); if (emailDistributionListLanguageExtraB == null) { return(NotFound()); } return(Ok(emailDistributionListLanguageExtraB)); } else { EmailDistributionListLanguage emailDistributionListLanguage = new EmailDistributionListLanguage(); emailDistributionListLanguage = emailDistributionListLanguageService.GetEmailDistributionListLanguageWithEmailDistributionListLanguageID(EmailDistributionListLanguageID); if (emailDistributionListLanguage == null) { return(NotFound()); } return(Ok(emailDistributionListLanguage)); } } }
public void GetEmailDistributionListLanguageWithEmailDistributionListLanguageID__emailDistributionListLanguage_EmailDistributionListLanguageID__Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { EmailDistributionListLanguageService emailDistributionListLanguageService = new EmailDistributionListLanguageService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); EmailDistributionListLanguage emailDistributionListLanguage = (from c in dbTestDB.EmailDistributionListLanguages select c).FirstOrDefault(); Assert.IsNotNull(emailDistributionListLanguage); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { emailDistributionListLanguageService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { EmailDistributionListLanguage emailDistributionListLanguageRet = emailDistributionListLanguageService.GetEmailDistributionListLanguageWithEmailDistributionListLanguageID(emailDistributionListLanguage.EmailDistributionListLanguageID); CheckEmailDistributionListLanguageFields(new List <EmailDistributionListLanguage>() { emailDistributionListLanguageRet }); Assert.AreEqual(emailDistributionListLanguage.EmailDistributionListLanguageID, emailDistributionListLanguageRet.EmailDistributionListLanguageID); } else { //Assert.AreEqual(true, false); } } } } }