public IHttpActionResult GetTVTypeUserAuthorizationWithID([FromUri] int TVTypeUserAuthorizationID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                TVTypeUserAuthorizationService tvTypeUserAuthorizationService = new TVTypeUserAuthorizationService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                tvTypeUserAuthorizationService.Query = tvTypeUserAuthorizationService.FillQuery(typeof(TVTypeUserAuthorization), lang, 0, 1, "", "", extra);

                if (tvTypeUserAuthorizationService.Query.Extra == "A")
                {
                    TVTypeUserAuthorizationExtraA tvTypeUserAuthorizationExtraA = new TVTypeUserAuthorizationExtraA();
                    tvTypeUserAuthorizationExtraA = tvTypeUserAuthorizationService.GetTVTypeUserAuthorizationExtraAWithTVTypeUserAuthorizationID(TVTypeUserAuthorizationID);

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

                    return(Ok(tvTypeUserAuthorizationExtraA));
                }
                else if (tvTypeUserAuthorizationService.Query.Extra == "B")
                {
                    TVTypeUserAuthorizationExtraB tvTypeUserAuthorizationExtraB = new TVTypeUserAuthorizationExtraB();
                    tvTypeUserAuthorizationExtraB = tvTypeUserAuthorizationService.GetTVTypeUserAuthorizationExtraBWithTVTypeUserAuthorizationID(TVTypeUserAuthorizationID);

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

                    return(Ok(tvTypeUserAuthorizationExtraB));
                }
                else
                {
                    TVTypeUserAuthorization tvTypeUserAuthorization = new TVTypeUserAuthorization();
                    tvTypeUserAuthorization = tvTypeUserAuthorizationService.GetTVTypeUserAuthorizationWithTVTypeUserAuthorizationID(TVTypeUserAuthorizationID);

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

                    return(Ok(tvTypeUserAuthorization));
                }
            }
        }
        public void GetTVTypeUserAuthorizationList_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"
                    })
                    {
                        TVTypeUserAuthorizationService tvTypeUserAuthorizationService = new TVTypeUserAuthorizationService(new Query()
                        {
                            Lang = culture.TwoLetterISOLanguageName
                        }, dbTestDB, ContactID);

                        tvTypeUserAuthorizationService.Query = tvTypeUserAuthorizationService.FillQuery(typeof(TVTypeUserAuthorization), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "TVTypeUserAuthorizationID,GT,2|TVTypeUserAuthorizationID,LT,5", extra);

                        List <TVTypeUserAuthorization> tvTypeUserAuthorizationDirectQueryList = new List <TVTypeUserAuthorization>();
                        tvTypeUserAuthorizationDirectQueryList = (from c in dbTestDB.TVTypeUserAuthorizations select c).Where(c => c.TVTypeUserAuthorizationID > 2 && c.TVTypeUserAuthorizationID < 5).ToList();

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            List <TVTypeUserAuthorization> tvTypeUserAuthorizationList = new List <TVTypeUserAuthorization>();
                            tvTypeUserAuthorizationList = tvTypeUserAuthorizationService.GetTVTypeUserAuthorizationList().ToList();
                            CheckTVTypeUserAuthorizationFields(tvTypeUserAuthorizationList);
                            Assert.AreEqual(tvTypeUserAuthorizationDirectQueryList[0].TVTypeUserAuthorizationID, tvTypeUserAuthorizationList[0].TVTypeUserAuthorizationID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }
        public IHttpActionResult GetTVTypeUserAuthorizationList([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))
            {
                TVTypeUserAuthorizationService tvTypeUserAuthorizationService = new TVTypeUserAuthorizationService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

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

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

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

                    if (tvTypeUserAuthorizationService.Query.HasErrors)
                    {
                        return(Ok(new List <TVTypeUserAuthorization>()
                        {
                            new TVTypeUserAuthorization()
                            {
                                HasErrors = tvTypeUserAuthorizationService.Query.HasErrors,
                                ValidationResults = tvTypeUserAuthorizationService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(tvTypeUserAuthorizationService.GetTVTypeUserAuthorizationList().ToList()));
                    }
                }
            }
        }