private async void GetExpedition() { _expedition = await _expeditionRepository.GetCurrent(_user); LogText(string.Format("{0}: Starting Expedition {1}", DateTime.Now, _expedition.Name), Color.Blue); _starSystemRepository = new StarSystemRepository(_expedition); _systemPointerRepository = new SystemPointerRepository(_expedition); _systemPointer = await _systemPointerRepository.GetCurrent(); }
/// <summary> /// Returns a Expedition instance /// </summary> /// <param name="parse"></param> /// <returns></returns> public static Expedition Map(ParseObject parseObject) { Expedition exp = new Expedition(); exp.ObjectId = parseObject.ObjectId; exp.CreatedAt = parseObject.CreatedAt.Value; exp.UpdatedAt = parseObject.UpdatedAt.Value; exp.Name = parseObject.Get<string>("name"); exp.Description = parseObject.Get<string>("description"); exp.Current = parseObject.Get<int>("current") == 1; exp.EndSystem = parseObject.Get<string>("endSystem"); exp.StartSystem = parseObject.Get<string>("startSystem"); exp.StartDate = parseObject.Get<DateTime?>("beginDate"); exp.EndDate = parseObject.Get<DateTime?>("endDate"); exp.Profit = parseObject.Get<double>("profit"); exp.TotalDistance = parseObject.Get<double>("totalDistance"); return exp; }
private async void ExpeditionComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (!_userSelectsExpedition) return; var exp = (Expedition)ExpeditionComboBox.SelectedItem; _currentExpedition = exp; await _persistentStore.SetCurrentExpedition(exp); Invoke(new Action<string, Color>(LogText), string.Format("Expedition {1} has {0} systems...", _persistentStore.StarSystems.Count(), _currentExpedition.Name), Color.Red); PopulateSystemGrid(); }
static async void RefreshExpeditionDropDown() { _userSelectsExpedition = false; if (null == _expeditions) { _expeditions = await _persistentStore.GetAllExpeditions(); } static_expedition_combo.DataSource = _expeditions.ToList(); static_expedition_combo.DisplayMember = "Name"; var currentExpedition = _expeditions.Where(a => a.Current).FirstOrDefault(); int itemIndex = -1; for (int index = 0; index < static_expedition_combo.Items.Count; index++) { var exp = (Expedition)static_expedition_combo.Items[index]; if (exp.ObjectId == currentExpedition.ObjectId) { itemIndex = index; _currentExpedition = exp; await _persistentStore.SetCurrentExpedition(exp); LogText(string.Format("Expedition {1} has {0} systems...", _persistentStore.StarSystems.Count(), _currentExpedition.Name), Color.Red); break; } } static_expedition_combo.SelectedIndex = itemIndex; PopulateSystemGrid(); _userSelectsExpedition = true; }
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; }
/// <summary> /// Constructor for StarSystemRepository Instance. Requires /// Expedition instance /// </summary> /// <param name="expedition"></param> public StarSystemRepository(Expedition expedition) { _expedition = expedition; }
public SystemPointerRepository(Expedition expedition) { _expedition = expedition; }
public Task<Expedition> UpdateExpedition(Expedition expedition) { throw new NotImplementedException(); }
public async Task<Expedition> InsertExpedition(Expedition expedition) { return await _expeditionRepository.Insert(expedition); }
public async Task<IEnumerable<StarSystem>> GetSystemsByExpedition(Expedition expedition) { return await _starSystemRepository.GetByExpedition(expedition); }
public async Task SetCurrentExpedition(Expedition expedition) { var starSystems = await GetSystemsByExpedition(expedition); StarSystems = starSystems; _currentExpedition = expedition; }