Esempio n. 1
0
        public IHttpActionResult GetReportSectionLanguageWithID([FromUri] int ReportSectionLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                ReportSectionLanguageService reportSectionLanguageService = new ReportSectionLanguageService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                reportSectionLanguageService.Query = reportSectionLanguageService.FillQuery(typeof(ReportSectionLanguage), lang, 0, 1, "", "", extra);

                if (reportSectionLanguageService.Query.Extra == "A")
                {
                    ReportSectionLanguageExtraA reportSectionLanguageExtraA = new ReportSectionLanguageExtraA();
                    reportSectionLanguageExtraA = reportSectionLanguageService.GetReportSectionLanguageExtraAWithReportSectionLanguageID(ReportSectionLanguageID);

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

                    return(Ok(reportSectionLanguageExtraA));
                }
                else if (reportSectionLanguageService.Query.Extra == "B")
                {
                    ReportSectionLanguageExtraB reportSectionLanguageExtraB = new ReportSectionLanguageExtraB();
                    reportSectionLanguageExtraB = reportSectionLanguageService.GetReportSectionLanguageExtraBWithReportSectionLanguageID(ReportSectionLanguageID);

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

                    return(Ok(reportSectionLanguageExtraB));
                }
                else
                {
                    ReportSectionLanguage reportSectionLanguage = new ReportSectionLanguage();
                    reportSectionLanguage = reportSectionLanguageService.GetReportSectionLanguageWithReportSectionLanguageID(ReportSectionLanguageID);

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

                    return(Ok(reportSectionLanguage));
                }
            }
        }
Esempio n. 2
0
        public IHttpActionResult GetReportSectionLanguageList([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))
            {
                ReportSectionLanguageService reportSectionLanguageService = new ReportSectionLanguageService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

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

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

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

                    if (reportSectionLanguageService.Query.HasErrors)
                    {
                        return(Ok(new List <ReportSectionLanguage>()
                        {
                            new ReportSectionLanguage()
                            {
                                HasErrors = reportSectionLanguageService.Query.HasErrors,
                                ValidationResults = reportSectionLanguageService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(reportSectionLanguageService.GetReportSectionLanguageList().ToList()));
                    }
                }
            }
        }