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);
                }
            }
        }
Ejemplo n.º 2
0
        public void GetDrogueRunPositionList_2Where_Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    foreach (string extra in new List <string>()
                    {
                        null, "A", "B", "C", "D", "E"
                    })
                    {
                        DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query()
                        {
                            Lang = culture.TwoLetterISOLanguageName
                        }, dbTestDB, ContactID);

                        drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPosition), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "DrogueRunPositionID,GT,2|DrogueRunPositionID,LT,5", extra);

                        List <DrogueRunPosition> drogueRunPositionDirectQueryList = new List <DrogueRunPosition>();
                        drogueRunPositionDirectQueryList = (from c in dbTestDB.DrogueRunPositions select c).Where(c => c.DrogueRunPositionID > 2 && c.DrogueRunPositionID < 5).ToList();

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            List <DrogueRunPosition> drogueRunPositionList = new List <DrogueRunPosition>();
                            drogueRunPositionList = drogueRunPositionService.GetDrogueRunPositionList().ToList();
                            CheckDrogueRunPositionFields(drogueRunPositionList);
                            Assert.AreEqual(drogueRunPositionDirectQueryList[0].DrogueRunPositionID, drogueRunPositionList[0].DrogueRunPositionID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }
        public IHttpActionResult GetDrogueRunPositionList([FromUri]string lang = "en", [FromUri]int skip = 0, [FromUri]int take = 200,
            [FromUri]string asc = "", [FromUri]string desc = "", [FromUri]string where = "", [FromUri]string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = lang }, db, ContactID);

                if (extra == "A") // QueryString contains [extra=A]
                {
                   drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPositionExtraA), lang, skip, take, asc, desc, where, extra);

                    if (drogueRunPositionService.Query.HasErrors)
                    {
                        return Ok(new List<DrogueRunPositionExtraA>()
                        {
                            new DrogueRunPositionExtraA()
                            {
                                HasErrors = drogueRunPositionService.Query.HasErrors,
                                ValidationResults = drogueRunPositionService.Query.ValidationResults,
                            },
                        }.ToList());
                    }
                    else
                    {
                        return Ok(drogueRunPositionService.GetDrogueRunPositionExtraAList().ToList());
                    }
                }
                else if (extra == "B") // QueryString contains [extra=B]
                {
                   drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPositionExtraB), lang, skip, take, asc, desc, where, extra);

                    if (drogueRunPositionService.Query.HasErrors)
                    {
                        return Ok(new List<DrogueRunPositionExtraB>()
                        {
                            new DrogueRunPositionExtraB()
                            {
                                HasErrors = drogueRunPositionService.Query.HasErrors,
                                ValidationResults = drogueRunPositionService.Query.ValidationResults,
                            },
                        }.ToList());
                    }
                    else
                    {
                        return Ok(drogueRunPositionService.GetDrogueRunPositionExtraBList().ToList());
                    }
                }
                else // QueryString has no parameter [extra] or extra is empty
                {
                   drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPosition), lang, skip, take, asc, desc, where, extra);

                    if (drogueRunPositionService.Query.HasErrors)
                    {
                        return Ok(new List<DrogueRunPosition>()
                        {
                            new DrogueRunPosition()
                            {
                                HasErrors = drogueRunPositionService.Query.HasErrors,
                                ValidationResults = drogueRunPositionService.Query.ValidationResults,
                            },
                        }.ToList());
                    }
                    else
                    {
                        return Ok(drogueRunPositionService.GetDrogueRunPositionList().ToList());
                    }
                }
            }
        }