Exemplo n.º 1
0
        /// <summary>
        /// Retrieves all StarSystems
        /// </summary>
        /// <returns>List of StarSystem instances</returns>
        public async Task <IEnumerable <StarSystem> > GetAll()
        {
            var n     = 1000;
            var s     = 0;
            var query = ParseObject.GetQuery("System");

            query.Limit(n).Skip(s).OrderBy("createdAt");
            IEnumerable <ParseObject> items = await query.FindAsync();

            var starSystems = items.ToList().Select(p => StarSystemMapper.Map(p));

            return(starSystems);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve StarSystem instance by name
        /// </summary>
        /// <param name="name"></param>
        /// <returns>Single StarSystem instance</returns>
        public async Task <StarSystem> GetByName(string name)
        {
            var query = from item in ParseObject.GetQuery("System")
                        where item.Get <string>("name") == name &&
                        item.Get <string>("expedition") == _expedition.ObjectId
                        select item;

            ParseObject parseObject = await query.FirstAsync();

            var starSystem = StarSystemMapper.Map(parseObject);

            return(starSystem);
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <StarSystem> > GetByExpedition(Expedition expedition)
        {
            if (null == expedition)
            {
                throw new ArgumentNullException("expedition");
            }
            if (string.IsNullOrWhiteSpace(expedition.ObjectId))
            {
                throw new Exception("Expedition.ObjectId is null");
            }
            List <StarSystem> starSystemList = new List <StarSystem>();
            int limit = 1000;
            int skip  = 0;

            for (int i = 0; i < 10; i++)   // 10K limit
            {
                var query = from item in ParseObject.GetQuery("System").Limit(limit).Skip(skip)
                            where item.Get <string>("expedition") == expedition.ObjectId
                            select item;

                IEnumerable <ParseObject> systems = await query.FindAsync();

                foreach (var sys in systems)
                {
                    starSystemList.Add(StarSystemMapper.Map(sys));
                }

                if (systems.ToList().Count < limit)
                {
                    break;
                }

                skip += limit;
            }


            return(starSystemList);
        }