Пример #1
0
        public async Task <List <DTO_GameCategory> > WS_GetDrawCategories()
        {
            DTO_GameCategory        gameCategory     = new DTO_GameCategory();
            List <DTO_GameCategory> gameCategoryList = new List <DTO_GameCategory>();

            try
            {
                HttpResponseMessage response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "GetDrawCategories"), gameCategory);

                response.EnsureSuccessStatusCode();
                var json = await response.Content.ReadAsStringAsync();

                var des = (Wrapper <DTO_GameCategory>)Newtonsoft.Json.JsonConvert.DeserializeObject(json, typeof(Wrapper <DTO_GameCategory>));
                var tempGameCategoryList = des.Data.ToList();

                foreach (var s in tempGameCategoryList)
                {
                    DTO_GameCategory newGameCategory = new DTO_GameCategory();
                    newGameCategory.CategoryID   = s.CategoryID;
                    newGameCategory.CategoryName = s.CategoryName;
                    gameCategoryList.Add(newGameCategory);
                }
            }
            catch (HttpRequestException hre)
            {
                Debug.WriteLine(hre.Message);
            }
            S_GameCategories.Instance.gameCategoryList = gameCategoryList;
            return(gameCategoryList);
        }
Пример #2
0
        public List <DTO_GameCategory> GetDrawCategories()
        {
            List <DTO_GameCategory> list = new List <DTO_GameCategory>();

            using (DB_122744_doodleEntities db = new DB_122744_doodleEntities())
            {
                var sqllist = db.drawCategories.ToList();
                foreach (var s in sqllist)
                {
                    DTO_GameCategory gamecategory = new DTO_GameCategory();
                    gamecategory.CategoryID   = s.DrawCategoryID;
                    gamecategory.CategoryName = s.DrawCategoryName;

                    list.Add(gamecategory);
                }
                return(list);
            }
        }