コード例 #1
0
        internal static async Task <List <NormalAlbum> > GetAllAlbums()
        {
            List <NormalAlbum> normalAlbums = new List <NormalAlbum>();
            var con = await SQLiteService.GetDbConnection();

            var albums = await con.Table <Album>().ToListAsync();

            var usercon = await SQLiteService.GetUserDbConnection();

            foreach (var item in albums)
            {
                List <UserAlbum> userAlbums;
                userAlbums = await usercon.Table <UserAlbum>().Where(p => p.Name == item.Name).ToListAsync();

                if (userAlbums.Count > 0)
                {
                    var normal = new NormalAlbum {
                        Name = item.Name, BuyPrice = item.BuyPrice, Cover = item.Cover, ForeignName = item.ForeignName, Number = item.Number, SalePrice = item.SalePrice, Source = item.Source, Owned = userAlbums[0].Owned
                    };
                    normalAlbums.Add(normal);
                }
                else
                {
                    var normal = new NormalAlbum {
                        Name = item.Name, BuyPrice = item.BuyPrice, Cover = item.Cover, ForeignName = item.ForeignName, Number = item.Number, SalePrice = item.SalePrice, Source = item.Source, Owned = false
                    };
                    normalAlbums.Add(normal);
                }
            }
            await con.CloseAsync();

            await usercon.CloseAsync();

            return(normalAlbums);
        }
コード例 #2
0
        /// <summary>
        /// 获取所有的昆虫
        /// </summary>
        /// <param name="bookCount">
        /// 图鉴开启数量
        /// </param>
        /// <param name="museumCount">
        /// 博物馆收藏数量
        /// </param>
        /// <param name="hemisphere">
        /// 选择南北半球
        /// </param>
        /// <returns>
        /// </returns>
        internal static List <NormalAnimal> GetAllInsects(out int bookCount, out int museumCount, Hemisphere hemisphere)
        {
            bookCount = 0; museumCount = 0;
            List <NormalAnimal> normalAnimals = new List <NormalAnimal>();

            using (var con = SQLiteService.GetDbConnection())
            {
                var animals = con.Table <AnimalsInsect>().ToList();
                foreach (var item in animals)
                {
                    var obj = Newtonsoft.Json.JsonConvert.DeserializeObject <Insect>(item.Data);

                    List <UserInsect> userInsect;
                    using (var usercon = SQLiteService.GetUserDbConnection())
                    {
                        userInsect = usercon.Table <UserInsect>().Where(p => p.Name == item.Name).ToList();
                    }
                    if (userInsect.Count > 0)
                    {
                        var owned      = userInsect[0].Owned;
                        var museumHave = userInsect[0].MuseumHave;

                        if (owned)
                        {
                            bookCount += 1;
                        }
                        if (museumHave)
                        {
                            museumCount += 1;
                        }

                        var normal = SelectHemisphereAndConstructInsect(hemisphere, obj, owned, museumHave);

                        normalAnimals.Add(normal);
                    }
                    else
                    {
                        var normal = SelectHemisphereAndConstructInsect(hemisphere, obj, false, false);

                        normalAnimals.Add(normal);
                    }
                }

                return(normalAnimals);
            }
        }
コード例 #3
0
        /// <summary>
        /// 获取所有的昆虫
        /// </summary>
        /// <param name="bookCount">
        /// 图鉴开启数量
        /// </param>
        /// <param name="museumCount">
        /// 博物馆收藏数量
        /// </param>
        /// <param name="hemisphere">
        /// 选择南北半球
        /// </param>
        /// <returns>
        /// </returns>
        internal static async Task <List <NormalAnimal> > GetAllInsects(Hemisphere hemisphere)
        {
            //bookCount = 0; museumCount = 0;
            List <NormalAnimal> normalAnimals = new List <NormalAnimal>();
            var con = await SQLiteService.GetDbConnection();

            var animals = await con.Table <AnimalsInsect>().OrderBy(p => p.Number).ToListAsync();

            var usercon = await SQLiteService.GetUserDbConnection();

            foreach (var item in animals)
            {
                //var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<Insect>(item.Data);

                List <UserInsect> userInsect;
                userInsect = await usercon.Table <UserInsect>().Where(p => p.Name == item.Name).ToListAsync();

                if (userInsect.Count > 0)
                {
                    var owned      = userInsect[0].Owned;
                    var museumHave = userInsect[0].MuseumHave;

                    //if (owned) bookCount += 1;
                    //if (museumHave) museumCount += 1;

                    var normal = SelectHemisphereAndConstructInsect(hemisphere, item, owned, museumHave);

                    normalAnimals.Add(normal);
                }
                else
                {
                    var normal = SelectHemisphereAndConstructInsect(hemisphere, item, false, false);

                    normalAnimals.Add(normal);
                }
            }
            await con.CloseAsync();

            await usercon.CloseAsync();

            return(normalAnimals);
        }
コード例 #4
0
        /// <summary>
        /// 获取所有的鱼
        /// </summary>
        /// <param name="bookCount">
        /// 图鉴开启数量
        /// </param>
        /// <param name="museumCount">
        /// 博物馆收藏数量
        /// </param>
        /// <param name="hemisphere">
        /// 选择南北半球
        /// </param>
        /// <returns>
        /// </returns>
        internal static async Task <List <NormalAnimal> > GetAllFishes(Hemisphere hemisphere)
        {
            //bookCount = 0; museumCount = 0;
            List <NormalAnimal> normalAnimals = new List <NormalAnimal>();
            var con = await SQLiteService.GetDbConnection();

            var animals = await con.Table <AnimalsFish>().OrderBy(p => p.Number).ToListAsync();

            var usercon = await SQLiteService.GetUserDbConnection();

            foreach (var item in animals)
            {
                List <UserFish> userFish;
                userFish = await usercon.Table <UserFish>().Where(p => p.Name == item.Name).ToListAsync();

                if (userFish.Count > 0)
                {
                    var owned      = userFish[0].Owned;
                    var museumHave = userFish[0].MuseumHave;
                    //if (owned) bookCount += 1;
                    //if (museumHave) museumCount += 1;

                    var normal = SelectHemisphereAndConstructFish(hemisphere, item, owned, museumHave);
                    normalAnimals.Add(normal);
                }
                else
                {
                    var normal = SelectHemisphereAndConstructFish(hemisphere, item, false, false);
                    normalAnimals.Add(normal);
                }
            }
            await con.CloseAsync();

            await usercon.CloseAsync();

            return(normalAnimals);
        }