public IHttpActionResult GetPolSourceObservationWithID([FromUri] int PolSourceObservationID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                PolSourceObservationService polSourceObservationService = new PolSourceObservationService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                polSourceObservationService.Query = polSourceObservationService.FillQuery(typeof(PolSourceObservation), lang, 0, 1, "", "", extra);

                if (polSourceObservationService.Query.Extra == "A")
                {
                    PolSourceObservationExtraA polSourceObservationExtraA = new PolSourceObservationExtraA();
                    polSourceObservationExtraA = polSourceObservationService.GetPolSourceObservationExtraAWithPolSourceObservationID(PolSourceObservationID);

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

                    return(Ok(polSourceObservationExtraA));
                }
                else if (polSourceObservationService.Query.Extra == "B")
                {
                    PolSourceObservationExtraB polSourceObservationExtraB = new PolSourceObservationExtraB();
                    polSourceObservationExtraB = polSourceObservationService.GetPolSourceObservationExtraBWithPolSourceObservationID(PolSourceObservationID);

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

                    return(Ok(polSourceObservationExtraB));
                }
                else
                {
                    PolSourceObservation polSourceObservation = new PolSourceObservation();
                    polSourceObservation = polSourceObservationService.GetPolSourceObservationWithPolSourceObservationID(PolSourceObservationID);

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

                    return(Ok(polSourceObservation));
                }
            }
        }
        public void GetPolSourceObservationList_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"
                    })
                    {
                        PolSourceObservationService polSourceObservationService = new PolSourceObservationService(new Query()
                        {
                            Lang = culture.TwoLetterISOLanguageName
                        }, dbTestDB, ContactID);

                        polSourceObservationService.Query = polSourceObservationService.FillQuery(typeof(PolSourceObservation), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "PolSourceObservationID,GT,2|PolSourceObservationID,LT,5", extra);

                        List <PolSourceObservation> polSourceObservationDirectQueryList = new List <PolSourceObservation>();
                        polSourceObservationDirectQueryList = (from c in dbTestDB.PolSourceObservations select c).Where(c => c.PolSourceObservationID > 2 && c.PolSourceObservationID < 5).ToList();

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            List <PolSourceObservation> polSourceObservationList = new List <PolSourceObservation>();
                            polSourceObservationList = polSourceObservationService.GetPolSourceObservationList().ToList();
                            CheckPolSourceObservationFields(polSourceObservationList);
                            Assert.AreEqual(polSourceObservationDirectQueryList[0].PolSourceObservationID, polSourceObservationList[0].PolSourceObservationID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }
        public IHttpActionResult GetPolSourceObservationList([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))
            {
                PolSourceObservationService polSourceObservationService = new PolSourceObservationService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

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

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

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

                    if (polSourceObservationService.Query.HasErrors)
                    {
                        return(Ok(new List <PolSourceObservation>()
                        {
                            new PolSourceObservation()
                            {
                                HasErrors = polSourceObservationService.Query.HasErrors,
                                ValidationResults = polSourceObservationService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(polSourceObservationService.GetPolSourceObservationList().ToList()));
                    }
                }
            }
        }