Beispiel #1
0
        public IHttpActionResult GetVPResultWithID([FromUri] int VPResultID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                VPResultService vpResultService = new VPResultService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                vpResultService.Query = vpResultService.FillQuery(typeof(VPResult), lang, 0, 1, "", "", extra);

                if (vpResultService.Query.Extra == "A")
                {
                    VPResultExtraA vpResultExtraA = new VPResultExtraA();
                    vpResultExtraA = vpResultService.GetVPResultExtraAWithVPResultID(VPResultID);

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

                    return(Ok(vpResultExtraA));
                }
                else if (vpResultService.Query.Extra == "B")
                {
                    VPResultExtraB vpResultExtraB = new VPResultExtraB();
                    vpResultExtraB = vpResultService.GetVPResultExtraBWithVPResultID(VPResultID);

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

                    return(Ok(vpResultExtraB));
                }
                else
                {
                    VPResult vpResult = new VPResult();
                    vpResult = vpResultService.GetVPResultWithVPResultID(VPResultID);

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

                    return(Ok(vpResult));
                }
            }
        }
Beispiel #2
0
        public void GetVPResultWithVPResultID__vpResult_VPResultID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    VPResultService vpResultService = new VPResultService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    VPResult vpResult = (from c in dbTestDB.VPResults select c).FirstOrDefault();
                    Assert.IsNotNull(vpResult);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            VPResult vpResultRet = vpResultService.GetVPResultWithVPResultID(vpResult.VPResultID);
                            CheckVPResultFields(new List <VPResult>()
                            {
                                vpResultRet
                            });
                            Assert.AreEqual(vpResult.VPResultID, vpResultRet.VPResultID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }