Exemple #1
0
        public IHttpActionResult GetPolSourceSiteList([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))
            {
                PolSourceSiteService polSourceSiteService = new PolSourceSiteService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

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

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

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

                    if (polSourceSiteService.Query.HasErrors)
                    {
                        return(Ok(new List <PolSourceSite>()
                        {
                            new PolSourceSite()
                            {
                                HasErrors = polSourceSiteService.Query.HasErrors,
                                ValidationResults = polSourceSiteService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(polSourceSiteService.GetPolSourceSiteList().ToList()));
                    }
                }
            }
        }