public IHttpActionResult GetDrogueRunPositionWithID([FromUri]int DrogueRunPositionID, [FromUri]string lang = "en", [FromUri]string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID);

                drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPosition), lang, 0, 1, "", "", extra);

                if (drogueRunPositionService.Query.Extra == "A")
                {
                    DrogueRunPositionExtraA drogueRunPositionExtraA = new DrogueRunPositionExtraA();
                    drogueRunPositionExtraA = drogueRunPositionService.GetDrogueRunPositionExtraAWithDrogueRunPositionID(DrogueRunPositionID);

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

                    return Ok(drogueRunPositionExtraA);
                }
                else if (drogueRunPositionService.Query.Extra == "B")
                {
                    DrogueRunPositionExtraB drogueRunPositionExtraB = new DrogueRunPositionExtraB();
                    drogueRunPositionExtraB = drogueRunPositionService.GetDrogueRunPositionExtraBWithDrogueRunPositionID(DrogueRunPositionID);

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

                    return Ok(drogueRunPositionExtraB);
                }
                else
                {
                    DrogueRunPosition drogueRunPosition = new DrogueRunPosition();
                    drogueRunPosition = drogueRunPositionService.GetDrogueRunPositionWithDrogueRunPositionID(DrogueRunPositionID);

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

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

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    DrogueRunPosition drogueRunPosition = (from c in dbTestDB.DrogueRunPositions select c).FirstOrDefault();
                    Assert.IsNotNull(drogueRunPosition);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            DrogueRunPosition drogueRunPositionRet = drogueRunPositionService.GetDrogueRunPositionWithDrogueRunPositionID(drogueRunPosition.DrogueRunPositionID);
                            CheckDrogueRunPositionFields(new List <DrogueRunPosition>()
                            {
                                drogueRunPositionRet
                            });
                            Assert.AreEqual(drogueRunPosition.DrogueRunPositionID, drogueRunPositionRet.DrogueRunPositionID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }