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

                drogueRunService.Query = drogueRunService.FillQuery(typeof(DrogueRun), lang, 0, 1, "", "", extra);

                if (drogueRunService.Query.Extra == "A")
                {
                    DrogueRunExtraA drogueRunExtraA = new DrogueRunExtraA();
                    drogueRunExtraA = drogueRunService.GetDrogueRunExtraAWithDrogueRunID(DrogueRunID);

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

                    return(Ok(drogueRunExtraA));
                }
                else if (drogueRunService.Query.Extra == "B")
                {
                    DrogueRunExtraB drogueRunExtraB = new DrogueRunExtraB();
                    drogueRunExtraB = drogueRunService.GetDrogueRunExtraBWithDrogueRunID(DrogueRunID);

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

                    return(Ok(drogueRunExtraB));
                }
                else
                {
                    DrogueRun drogueRun = new DrogueRun();
                    drogueRun = drogueRunService.GetDrogueRunWithDrogueRunID(DrogueRunID);

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

                    return(Ok(drogueRun));
                }
            }
        }
Exemplo n.º 2
0
        public void GetDrogueRunWithDrogueRunID__drogueRun_DrogueRunID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    DrogueRunService drogueRunService = new DrogueRunService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    DrogueRun drogueRun = (from c in dbTestDB.DrogueRuns select c).FirstOrDefault();
                    Assert.IsNotNull(drogueRun);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            DrogueRun drogueRunRet = drogueRunService.GetDrogueRunWithDrogueRunID(drogueRun.DrogueRunID);
                            CheckDrogueRunFields(new List <DrogueRun>()
                            {
                                drogueRunRet
                            });
                            Assert.AreEqual(drogueRun.DrogueRunID, drogueRunRet.DrogueRunID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }