Ejemplo n.º 1
0
        public IHttpActionResult GetMWQMSiteWithID([FromUri] int MWQMSiteID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                MWQMSiteService mwqmSiteService = new MWQMSiteService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                mwqmSiteService.Query = mwqmSiteService.FillQuery(typeof(MWQMSite), lang, 0, 1, "", "", extra);

                if (mwqmSiteService.Query.Extra == "A")
                {
                    MWQMSiteExtraA mwqmSiteExtraA = new MWQMSiteExtraA();
                    mwqmSiteExtraA = mwqmSiteService.GetMWQMSiteExtraAWithMWQMSiteID(MWQMSiteID);

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

                    return(Ok(mwqmSiteExtraA));
                }
                else if (mwqmSiteService.Query.Extra == "B")
                {
                    MWQMSiteExtraB mwqmSiteExtraB = new MWQMSiteExtraB();
                    mwqmSiteExtraB = mwqmSiteService.GetMWQMSiteExtraBWithMWQMSiteID(MWQMSiteID);

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

                    return(Ok(mwqmSiteExtraB));
                }
                else
                {
                    MWQMSite mwqmSite = new MWQMSite();
                    mwqmSite = mwqmSiteService.GetMWQMSiteWithMWQMSiteID(MWQMSiteID);

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

                    return(Ok(mwqmSite));
                }
            }
        }
        public void GetMWQMSiteWithMWQMSiteID__mwqmSite_MWQMSiteID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    MWQMSiteService mwqmSiteService = new MWQMSiteService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    MWQMSite mwqmSite = (from c in dbTestDB.MWQMSites select c).FirstOrDefault();
                    Assert.IsNotNull(mwqmSite);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            MWQMSite mwqmSiteRet = mwqmSiteService.GetMWQMSiteWithMWQMSiteID(mwqmSite.MWQMSiteID);
                            CheckMWQMSiteFields(new List <MWQMSite>()
                            {
                                mwqmSiteRet
                            });
                            Assert.AreEqual(mwqmSite.MWQMSiteID, mwqmSiteRet.MWQMSiteID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }