コード例 #1
0
        public IHttpActionResult GetPolSourceSiteWithID([FromUri] int PolSourceSiteID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                PolSourceSiteService polSourceSiteService = new PolSourceSiteService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                polSourceSiteService.Query = polSourceSiteService.FillQuery(typeof(PolSourceSite), lang, 0, 1, "", "", extra);

                if (polSourceSiteService.Query.Extra == "A")
                {
                    PolSourceSiteExtraA polSourceSiteExtraA = new PolSourceSiteExtraA();
                    polSourceSiteExtraA = polSourceSiteService.GetPolSourceSiteExtraAWithPolSourceSiteID(PolSourceSiteID);

                    if (polSourceSiteExtraA == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(polSourceSiteExtraA));
                }
                else if (polSourceSiteService.Query.Extra == "B")
                {
                    PolSourceSiteExtraB polSourceSiteExtraB = new PolSourceSiteExtraB();
                    polSourceSiteExtraB = polSourceSiteService.GetPolSourceSiteExtraBWithPolSourceSiteID(PolSourceSiteID);

                    if (polSourceSiteExtraB == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(polSourceSiteExtraB));
                }
                else
                {
                    PolSourceSite polSourceSite = new PolSourceSite();
                    polSourceSite = polSourceSiteService.GetPolSourceSiteWithPolSourceSiteID(PolSourceSiteID);

                    if (polSourceSite == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(polSourceSite));
                }
            }
        }
コード例 #2
0
        public void GetPolSourceSiteWithPolSourceSiteID__polSourceSite_PolSourceSiteID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    PolSourceSiteService polSourceSiteService = new PolSourceSiteService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    PolSourceSite polSourceSite = (from c in dbTestDB.PolSourceSites select c).FirstOrDefault();
                    Assert.IsNotNull(polSourceSite);

                    foreach (string extra in new List <string>()
                    {
                        null, "A", "B", "C", "D", "E"
                    })
                    {
                        polSourceSiteService.Query.Extra = extra;

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            PolSourceSite polSourceSiteRet = polSourceSiteService.GetPolSourceSiteWithPolSourceSiteID(polSourceSite.PolSourceSiteID);
                            CheckPolSourceSiteFields(new List <PolSourceSite>()
                            {
                                polSourceSiteRet
                            });
                            Assert.AreEqual(polSourceSite.PolSourceSiteID, polSourceSiteRet.PolSourceSiteID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }