public IHttpActionResult GetMWQMSiteStartEndDateWithID([FromUri] int MWQMSiteStartEndDateID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { MWQMSiteStartEndDateService mwqmSiteStartEndDateService = new MWQMSiteStartEndDateService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); mwqmSiteStartEndDateService.Query = mwqmSiteStartEndDateService.FillQuery(typeof(MWQMSiteStartEndDate), lang, 0, 1, "", "", extra); if (mwqmSiteStartEndDateService.Query.Extra == "A") { MWQMSiteStartEndDateExtraA mwqmSiteStartEndDateExtraA = new MWQMSiteStartEndDateExtraA(); mwqmSiteStartEndDateExtraA = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateExtraAWithMWQMSiteStartEndDateID(MWQMSiteStartEndDateID); if (mwqmSiteStartEndDateExtraA == null) { return(NotFound()); } return(Ok(mwqmSiteStartEndDateExtraA)); } else if (mwqmSiteStartEndDateService.Query.Extra == "B") { MWQMSiteStartEndDateExtraB mwqmSiteStartEndDateExtraB = new MWQMSiteStartEndDateExtraB(); mwqmSiteStartEndDateExtraB = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateExtraBWithMWQMSiteStartEndDateID(MWQMSiteStartEndDateID); if (mwqmSiteStartEndDateExtraB == null) { return(NotFound()); } return(Ok(mwqmSiteStartEndDateExtraB)); } else { MWQMSiteStartEndDate mwqmSiteStartEndDate = new MWQMSiteStartEndDate(); mwqmSiteStartEndDate = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateID(MWQMSiteStartEndDateID); if (mwqmSiteStartEndDate == null) { return(NotFound()); } return(Ok(mwqmSiteStartEndDate)); } } }
public void GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateID__mwqmSiteStartEndDate_MWQMSiteStartEndDateID__Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { MWQMSiteStartEndDateService mwqmSiteStartEndDateService = new MWQMSiteStartEndDateService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); MWQMSiteStartEndDate mwqmSiteStartEndDate = (from c in dbTestDB.MWQMSiteStartEndDates select c).FirstOrDefault(); Assert.IsNotNull(mwqmSiteStartEndDate); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { mwqmSiteStartEndDateService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { MWQMSiteStartEndDate mwqmSiteStartEndDateRet = mwqmSiteStartEndDateService.GetMWQMSiteStartEndDateWithMWQMSiteStartEndDateID(mwqmSiteStartEndDate.MWQMSiteStartEndDateID); CheckMWQMSiteStartEndDateFields(new List <MWQMSiteStartEndDate>() { mwqmSiteStartEndDateRet }); Assert.AreEqual(mwqmSiteStartEndDate.MWQMSiteStartEndDateID, mwqmSiteStartEndDateRet.MWQMSiteStartEndDateID); } else { //Assert.AreEqual(true, false); } } } } }