Exemple #1
0
        public IHttpActionResult GetMapInfoWithID([FromUri] int MapInfoID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                MapInfoService mapInfoService = new MapInfoService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                mapInfoService.Query = mapInfoService.FillQuery(typeof(MapInfo), lang, 0, 1, "", "", extra);

                if (mapInfoService.Query.Extra == "A")
                {
                    MapInfoExtraA mapInfoExtraA = new MapInfoExtraA();
                    mapInfoExtraA = mapInfoService.GetMapInfoExtraAWithMapInfoID(MapInfoID);

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

                    return(Ok(mapInfoExtraA));
                }
                else if (mapInfoService.Query.Extra == "B")
                {
                    MapInfoExtraB mapInfoExtraB = new MapInfoExtraB();
                    mapInfoExtraB = mapInfoService.GetMapInfoExtraBWithMapInfoID(MapInfoID);

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

                    return(Ok(mapInfoExtraB));
                }
                else
                {
                    MapInfo mapInfo = new MapInfo();
                    mapInfo = mapInfoService.GetMapInfoWithMapInfoID(MapInfoID);

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

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

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    MapInfoService mapInfoService = new MapInfoService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    MapInfo mapInfo = (from c in dbTestDB.MapInfos select c).FirstOrDefault();
                    Assert.IsNotNull(mapInfo);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            MapInfo mapInfoRet = mapInfoService.GetMapInfoWithMapInfoID(mapInfo.MapInfoID);
                            CheckMapInfoFields(new List <MapInfo>()
                            {
                                mapInfoRet
                            });
                            Assert.AreEqual(mapInfo.MapInfoID, mapInfoRet.MapInfoID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }