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

                ratingCurveValueService.Query = ratingCurveValueService.FillQuery(typeof(RatingCurveValue), lang, 0, 1, "", "", extra);

                if (ratingCurveValueService.Query.Extra == "A")
                {
                    RatingCurveValueExtraA ratingCurveValueExtraA = new RatingCurveValueExtraA();
                    ratingCurveValueExtraA = ratingCurveValueService.GetRatingCurveValueExtraAWithRatingCurveValueID(RatingCurveValueID);

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

                    return(Ok(ratingCurveValueExtraA));
                }
                else if (ratingCurveValueService.Query.Extra == "B")
                {
                    RatingCurveValueExtraB ratingCurveValueExtraB = new RatingCurveValueExtraB();
                    ratingCurveValueExtraB = ratingCurveValueService.GetRatingCurveValueExtraBWithRatingCurveValueID(RatingCurveValueID);

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

                    return(Ok(ratingCurveValueExtraB));
                }
                else
                {
                    RatingCurveValue ratingCurveValue = new RatingCurveValue();
                    ratingCurveValue = ratingCurveValueService.GetRatingCurveValueWithRatingCurveValueID(RatingCurveValueID);

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

                    return(Ok(ratingCurveValue));
                }
            }
        }
        public void GetRatingCurveValueWithRatingCurveValueID__ratingCurveValue_RatingCurveValueID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    RatingCurveValueService ratingCurveValueService = new RatingCurveValueService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    RatingCurveValue ratingCurveValue = (from c in dbTestDB.RatingCurveValues select c).FirstOrDefault();
                    Assert.IsNotNull(ratingCurveValue);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            RatingCurveValue ratingCurveValueRet = ratingCurveValueService.GetRatingCurveValueWithRatingCurveValueID(ratingCurveValue.RatingCurveValueID);
                            CheckRatingCurveValueFields(new List <RatingCurveValue>()
                            {
                                ratingCurveValueRet
                            });
                            Assert.AreEqual(ratingCurveValue.RatingCurveValueID, ratingCurveValueRet.RatingCurveValueID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }