Exemplo n.º 1
0
        public IHttpActionResult GetSamplingPlanSubsectorSiteWithID([FromUri] int SamplingPlanSubsectorSiteID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                SamplingPlanSubsectorSiteService samplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                samplingPlanSubsectorSiteService.Query = samplingPlanSubsectorSiteService.FillQuery(typeof(SamplingPlanSubsectorSite), lang, 0, 1, "", "", extra);

                if (samplingPlanSubsectorSiteService.Query.Extra == "A")
                {
                    SamplingPlanSubsectorSiteExtraA samplingPlanSubsectorSiteExtraA = new SamplingPlanSubsectorSiteExtraA();
                    samplingPlanSubsectorSiteExtraA = samplingPlanSubsectorSiteService.GetSamplingPlanSubsectorSiteExtraAWithSamplingPlanSubsectorSiteID(SamplingPlanSubsectorSiteID);

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

                    return(Ok(samplingPlanSubsectorSiteExtraA));
                }
                else if (samplingPlanSubsectorSiteService.Query.Extra == "B")
                {
                    SamplingPlanSubsectorSiteExtraB samplingPlanSubsectorSiteExtraB = new SamplingPlanSubsectorSiteExtraB();
                    samplingPlanSubsectorSiteExtraB = samplingPlanSubsectorSiteService.GetSamplingPlanSubsectorSiteExtraBWithSamplingPlanSubsectorSiteID(SamplingPlanSubsectorSiteID);

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

                    return(Ok(samplingPlanSubsectorSiteExtraB));
                }
                else
                {
                    SamplingPlanSubsectorSite samplingPlanSubsectorSite = new SamplingPlanSubsectorSite();
                    samplingPlanSubsectorSite = samplingPlanSubsectorSiteService.GetSamplingPlanSubsectorSiteWithSamplingPlanSubsectorSiteID(SamplingPlanSubsectorSiteID);

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

                    return(Ok(samplingPlanSubsectorSite));
                }
            }
        }
        public void GetSamplingPlanSubsectorSiteWithSamplingPlanSubsectorSiteID__samplingPlanSubsectorSite_SamplingPlanSubsectorSiteID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    SamplingPlanSubsectorSiteService samplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    SamplingPlanSubsectorSite samplingPlanSubsectorSite = (from c in dbTestDB.SamplingPlanSubsectorSites select c).FirstOrDefault();
                    Assert.IsNotNull(samplingPlanSubsectorSite);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            SamplingPlanSubsectorSite samplingPlanSubsectorSiteRet = samplingPlanSubsectorSiteService.GetSamplingPlanSubsectorSiteWithSamplingPlanSubsectorSiteID(samplingPlanSubsectorSite.SamplingPlanSubsectorSiteID);
                            CheckSamplingPlanSubsectorSiteFields(new List <SamplingPlanSubsectorSite>()
                            {
                                samplingPlanSubsectorSiteRet
                            });
                            Assert.AreEqual(samplingPlanSubsectorSite.SamplingPlanSubsectorSiteID, samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }