Beispiel #1
0
        public IHttpActionResult GetDocTemplateWithID([FromUri] int DocTemplateID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                DocTemplateService docTemplateService = new DocTemplateService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                docTemplateService.Query = docTemplateService.FillQuery(typeof(DocTemplate), lang, 0, 1, "", "", extra);

                if (docTemplateService.Query.Extra == "A")
                {
                    DocTemplateExtraA docTemplateExtraA = new DocTemplateExtraA();
                    docTemplateExtraA = docTemplateService.GetDocTemplateExtraAWithDocTemplateID(DocTemplateID);

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

                    return(Ok(docTemplateExtraA));
                }
                else if (docTemplateService.Query.Extra == "B")
                {
                    DocTemplateExtraB docTemplateExtraB = new DocTemplateExtraB();
                    docTemplateExtraB = docTemplateService.GetDocTemplateExtraBWithDocTemplateID(DocTemplateID);

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

                    return(Ok(docTemplateExtraB));
                }
                else
                {
                    DocTemplate docTemplate = new DocTemplate();
                    docTemplate = docTemplateService.GetDocTemplateWithDocTemplateID(DocTemplateID);

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

                    return(Ok(docTemplate));
                }
            }
        }
Beispiel #2
0
        public void GetDocTemplateWithDocTemplateID__docTemplate_DocTemplateID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    DocTemplateService docTemplateService = new DocTemplateService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    DocTemplate docTemplate = (from c in dbTestDB.DocTemplates select c).FirstOrDefault();
                    Assert.IsNotNull(docTemplate);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            DocTemplate docTemplateRet = docTemplateService.GetDocTemplateWithDocTemplateID(docTemplate.DocTemplateID);
                            CheckDocTemplateFields(new List <DocTemplate>()
                            {
                                docTemplateRet
                            });
                            Assert.AreEqual(docTemplate.DocTemplateID, docTemplateRet.DocTemplateID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }