public IHttpActionResult GetHelpDocWithID([FromUri] int HelpDocID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                HelpDocService helpDocService = new HelpDocService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                helpDocService.Query = helpDocService.FillQuery(typeof(HelpDoc), lang, 0, 1, "", "", extra);

                if (helpDocService.Query.Extra == "A")
                {
                    HelpDocExtraA helpDocExtraA = new HelpDocExtraA();
                    helpDocExtraA = helpDocService.GetHelpDocExtraAWithHelpDocID(HelpDocID);

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

                    return(Ok(helpDocExtraA));
                }
                else if (helpDocService.Query.Extra == "B")
                {
                    HelpDocExtraB helpDocExtraB = new HelpDocExtraB();
                    helpDocExtraB = helpDocService.GetHelpDocExtraBWithHelpDocID(HelpDocID);

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

                    return(Ok(helpDocExtraB));
                }
                else
                {
                    HelpDoc helpDoc = new HelpDoc();
                    helpDoc = helpDocService.GetHelpDocWithHelpDocID(HelpDocID);

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

                    return(Ok(helpDoc));
                }
            }
        }
Пример #2
0
        public void GetHelpDocWithHelpDocID__helpDoc_HelpDocID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    HelpDocService helpDocService = new HelpDocService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    HelpDoc helpDoc = (from c in dbTestDB.HelpDocs select c).FirstOrDefault();
                    Assert.IsNotNull(helpDoc);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            HelpDoc helpDocRet = helpDocService.GetHelpDocWithHelpDocID(helpDoc.HelpDocID);
                            CheckHelpDocFields(new List <HelpDoc>()
                            {
                                helpDocRet
                            });
                            Assert.AreEqual(helpDoc.HelpDocID, helpDocRet.HelpDocID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }