public IHttpActionResult GetTVFileWithID([FromUri] int TVFileID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                TVFileService tvFileService = new TVFileService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                tvFileService.Query = tvFileService.FillQuery(typeof(TVFile), lang, 0, 1, "", "", extra);

                if (tvFileService.Query.Extra == "A")
                {
                    TVFileExtraA tvFileExtraA = new TVFileExtraA();
                    tvFileExtraA = tvFileService.GetTVFileExtraAWithTVFileID(TVFileID);

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

                    return(Ok(tvFileExtraA));
                }
                else if (tvFileService.Query.Extra == "B")
                {
                    TVFileExtraB tvFileExtraB = new TVFileExtraB();
                    tvFileExtraB = tvFileService.GetTVFileExtraBWithTVFileID(TVFileID);

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

                    return(Ok(tvFileExtraB));
                }
                else
                {
                    TVFile tvFile = new TVFile();
                    tvFile = tvFileService.GetTVFileWithTVFileID(TVFileID);

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

                    return(Ok(tvFile));
                }
            }
        }
        public void GetTVFileList_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"
                    })
                    {
                        TVFileService tvFileService = new TVFileService(new Query()
                        {
                            Lang = culture.TwoLetterISOLanguageName
                        }, dbTestDB, ContactID);

                        tvFileService.Query = tvFileService.FillQuery(typeof(TVFile), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "TVFileID,GT,2|TVFileID,LT,5", extra);

                        List <TVFile> tvFileDirectQueryList = new List <TVFile>();
                        tvFileDirectQueryList = (from c in dbTestDB.TVFiles select c).Where(c => c.TVFileID > 2 && c.TVFileID < 5).ToList();

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            List <TVFile> tvFileList = new List <TVFile>();
                            tvFileList = tvFileService.GetTVFileList().ToList();
                            CheckTVFileFields(tvFileList);
                            Assert.AreEqual(tvFileDirectQueryList[0].TVFileID, tvFileList[0].TVFileID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }
        public IHttpActionResult GetTVFileList([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))
            {
                TVFileService tvFileService = new TVFileService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

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

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

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

                    if (tvFileService.Query.HasErrors)
                    {
                        return(Ok(new List <TVFile>()
                        {
                            new TVFile()
                            {
                                HasErrors = tvFileService.Query.HasErrors,
                                ValidationResults = tvFileService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(tvFileService.GetTVFileList().ToList()));
                    }
                }
            }
        }