Example #1
0
        public IHttpActionResult GetMWQMSubsectorLanguageWithID([FromUri] int MWQMSubsectorLanguageID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                MWQMSubsectorLanguageService mwqmSubsectorLanguageService = new MWQMSubsectorLanguageService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                mwqmSubsectorLanguageService.Query = mwqmSubsectorLanguageService.FillQuery(typeof(MWQMSubsectorLanguage), lang, 0, 1, "", "", extra);

                if (mwqmSubsectorLanguageService.Query.Extra == "A")
                {
                    MWQMSubsectorLanguageExtraA mwqmSubsectorLanguageExtraA = new MWQMSubsectorLanguageExtraA();
                    mwqmSubsectorLanguageExtraA = mwqmSubsectorLanguageService.GetMWQMSubsectorLanguageExtraAWithMWQMSubsectorLanguageID(MWQMSubsectorLanguageID);

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

                    return(Ok(mwqmSubsectorLanguageExtraA));
                }
                else if (mwqmSubsectorLanguageService.Query.Extra == "B")
                {
                    MWQMSubsectorLanguageExtraB mwqmSubsectorLanguageExtraB = new MWQMSubsectorLanguageExtraB();
                    mwqmSubsectorLanguageExtraB = mwqmSubsectorLanguageService.GetMWQMSubsectorLanguageExtraBWithMWQMSubsectorLanguageID(MWQMSubsectorLanguageID);

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

                    return(Ok(mwqmSubsectorLanguageExtraB));
                }
                else
                {
                    MWQMSubsectorLanguage mwqmSubsectorLanguage = new MWQMSubsectorLanguage();
                    mwqmSubsectorLanguage = mwqmSubsectorLanguageService.GetMWQMSubsectorLanguageWithMWQMSubsectorLanguageID(MWQMSubsectorLanguageID);

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

                    return(Ok(mwqmSubsectorLanguage));
                }
            }
        }
Example #2
0
        public void GetMWQMSubsectorLanguageWithMWQMSubsectorLanguageID__mwqmSubsectorLanguage_MWQMSubsectorLanguageID__Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    MWQMSubsectorLanguageService mwqmSubsectorLanguageService = new MWQMSubsectorLanguageService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);
                    MWQMSubsectorLanguage mwqmSubsectorLanguage = (from c in dbTestDB.MWQMSubsectorLanguages select c).FirstOrDefault();
                    Assert.IsNotNull(mwqmSubsectorLanguage);

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

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            MWQMSubsectorLanguage mwqmSubsectorLanguageRet = mwqmSubsectorLanguageService.GetMWQMSubsectorLanguageWithMWQMSubsectorLanguageID(mwqmSubsectorLanguage.MWQMSubsectorLanguageID);
                            CheckMWQMSubsectorLanguageFields(new List <MWQMSubsectorLanguage>()
                            {
                                mwqmSubsectorLanguageRet
                            });
                            Assert.AreEqual(mwqmSubsectorLanguage.MWQMSubsectorLanguageID, mwqmSubsectorLanguageRet.MWQMSubsectorLanguageID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }