public IHttpActionResult GetReportSectionWithID([FromUri] int ReportSectionID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                ReportSectionService reportSectionService = new ReportSectionService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSection), lang, 0, 1, "", "", extra);

                if (reportSectionService.Query.Extra == "A")
                {
                    ReportSectionExtraA reportSectionExtraA = new ReportSectionExtraA();
                    reportSectionExtraA = reportSectionService.GetReportSectionExtraAWithReportSectionID(ReportSectionID);

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

                    return(Ok(reportSectionExtraA));
                }
                else if (reportSectionService.Query.Extra == "B")
                {
                    ReportSectionExtraB reportSectionExtraB = new ReportSectionExtraB();
                    reportSectionExtraB = reportSectionService.GetReportSectionExtraBWithReportSectionID(ReportSectionID);

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

                    return(Ok(reportSectionExtraB));
                }
                else
                {
                    ReportSection reportSection = new ReportSection();
                    reportSection = reportSectionService.GetReportSectionWithReportSectionID(ReportSectionID);

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

                    return(Ok(reportSection));
                }
            }
        }
Exemple #2
0
        public void GetReportSectionWithReportSectionID__reportSection_ReportSectionID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    ReportSectionService reportSectionService = new ReportSectionService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    ReportSection reportSection = (from c in dbTestDB.ReportSections select c).FirstOrDefault();
                    Assert.IsNotNull(reportSection);

                    foreach (string extra in new List <string>()
                    {
                        null, "A", "B", "C", "D", "E"
                    })
                    {
                        reportSectionService.Query.Extra = extra;

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            ReportSection reportSectionRet = reportSectionService.GetReportSectionWithReportSectionID(reportSection.ReportSectionID);
                            CheckReportSectionFields(new List <ReportSection>()
                            {
                                reportSectionRet
                            });
                            Assert.AreEqual(reportSection.ReportSectionID, reportSectionRet.ReportSectionID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }