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

                tideSiteService.Query = tideSiteService.FillQuery(typeof(TideSite), lang, 0, 1, "", "", extra);

                if (tideSiteService.Query.Extra == "A")
                {
                    TideSiteExtraA tideSiteExtraA = new TideSiteExtraA();
                    tideSiteExtraA = tideSiteService.GetTideSiteExtraAWithTideSiteID(TideSiteID);

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

                    return(Ok(tideSiteExtraA));
                }
                else if (tideSiteService.Query.Extra == "B")
                {
                    TideSiteExtraB tideSiteExtraB = new TideSiteExtraB();
                    tideSiteExtraB = tideSiteService.GetTideSiteExtraBWithTideSiteID(TideSiteID);

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

                    return(Ok(tideSiteExtraB));
                }
                else
                {
                    TideSite tideSite = new TideSite();
                    tideSite = tideSiteService.GetTideSiteWithTideSiteID(TideSiteID);

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

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

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    foreach (string extra in new List <string>()
                    {
                        null, "A", "B", "C", "D", "E"
                    })
                    {
                        TideSiteService tideSiteService = new TideSiteService(new Query()
                        {
                            Lang = culture.TwoLetterISOLanguageName
                        }, dbTestDB, ContactID);

                        tideSiteService.Query = tideSiteService.FillQuery(typeof(TideSite), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "TideSiteID,GT,2|TideSiteID,LT,5", extra);

                        List <TideSite> tideSiteDirectQueryList = new List <TideSite>();
                        tideSiteDirectQueryList = (from c in dbTestDB.TideSites select c).Where(c => c.TideSiteID > 2 && c.TideSiteID < 5).ToList();

                        if (string.IsNullOrWhiteSpace(extra))
                        {
                            List <TideSite> tideSiteList = new List <TideSite>();
                            tideSiteList = tideSiteService.GetTideSiteList().ToList();
                            CheckTideSiteFields(tideSiteList);
                            Assert.AreEqual(tideSiteDirectQueryList[0].TideSiteID, tideSiteList[0].TideSiteID);
                        }
                        else
                        {
                            //Assert.AreEqual(true, false);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public IHttpActionResult GetTideSiteList([FromUri] string lang = "en", [FromUri] int skip  = 0, [FromUri] int take      = 200,
                                                 [FromUri] string asc  = "", [FromUri] string desc = "", [FromUri] string where = "", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                TideSiteService tideSiteService = new TideSiteService(new Query()
                {
                    Lang = lang
                }, db, ContactID);

                if (extra == "A") // QueryString contains [extra=A]
                {
                    tideSiteService.Query = tideSiteService.FillQuery(typeof(TideSiteExtraA), lang, skip, take, asc, desc, where, extra);

                    if (tideSiteService.Query.HasErrors)
                    {
                        return(Ok(new List <TideSiteExtraA>()
                        {
                            new TideSiteExtraA()
                            {
                                HasErrors = tideSiteService.Query.HasErrors,
                                ValidationResults = tideSiteService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(tideSiteService.GetTideSiteExtraAList().ToList()));
                    }
                }
                else if (extra == "B") // QueryString contains [extra=B]
                {
                    tideSiteService.Query = tideSiteService.FillQuery(typeof(TideSiteExtraB), lang, skip, take, asc, desc, where, extra);

                    if (tideSiteService.Query.HasErrors)
                    {
                        return(Ok(new List <TideSiteExtraB>()
                        {
                            new TideSiteExtraB()
                            {
                                HasErrors = tideSiteService.Query.HasErrors,
                                ValidationResults = tideSiteService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(tideSiteService.GetTideSiteExtraBList().ToList()));
                    }
                }
                else // QueryString has no parameter [extra] or extra is empty
                {
                    tideSiteService.Query = tideSiteService.FillQuery(typeof(TideSite), lang, skip, take, asc, desc, where, extra);

                    if (tideSiteService.Query.HasErrors)
                    {
                        return(Ok(new List <TideSite>()
                        {
                            new TideSite()
                            {
                                HasErrors = tideSiteService.Query.HasErrors,
                                ValidationResults = tideSiteService.Query.ValidationResults,
                            },
                        }.ToList()));
                    }
                    else
                    {
                        return(Ok(tideSiteService.GetTideSiteList().ToList()));
                    }
                }
            }
        }