示例#1
0
        public IHttpActionResult GetClassificationWithID([FromUri] int ClassificationID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                ClassificationService classificationService = new ClassificationService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                classificationService.Query = classificationService.FillQuery(typeof(Classification), lang, 0, 1, "", "", extra);

                if (classificationService.Query.Extra == "A")
                {
                    ClassificationExtraA classificationExtraA = new ClassificationExtraA();
                    classificationExtraA = classificationService.GetClassificationExtraAWithClassificationID(ClassificationID);

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

                    return(Ok(classificationExtraA));
                }
                else if (classificationService.Query.Extra == "B")
                {
                    ClassificationExtraB classificationExtraB = new ClassificationExtraB();
                    classificationExtraB = classificationService.GetClassificationExtraBWithClassificationID(ClassificationID);

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

                    return(Ok(classificationExtraB));
                }
                else
                {
                    Classification classification = new Classification();
                    classification = classificationService.GetClassificationWithClassificationID(ClassificationID);

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

                    return(Ok(classification));
                }
            }
        }