public async static void SetGpsPositionsWithProject(GpsPosition p) { if (!App.User.Id.HasValue) throw new InvalidOperationException ("unauthorized user"); string url = _baseUrl + "gps"; await _client.PostAsync<GpsPosition> (url, p); }
public Projects(GpsPosition gpsPos, IList<GpsPosition> gpsPositions) { InitializeComponent (); ObservableCollection<Toggl.Project> allProjects = CommonInit (); var projects = allProjects.Where (proj => !gpsPositions.Any(pos => proj.Id.Equals(pos.ProjectId))); list.ItemsSource = projects; var cnt = projects.Count(); var name = App.User.FullName; list.Header = new Label { Text = string.Format ("{0} Project{1} for {2}", cnt, (cnt == 1 ? "" : "s"), name.Replace("_", " ").Replace("r", "R")), XAlign = TextAlignment.Center }; list.ItemTapped += (sender, e) => { var project = e.Item as Toggl.Project; gpsPos.ProjectId = project.Id.Value; var added = App.AddGpsPosition(gpsPos); App.Notificator.Notify (ToastNotificationType.Info, "XToggl", "Position notification " + (added ? "activated" : "already active") , TimeSpan.FromSeconds (1.0), null); Navigation.PopAsync(); }; }
public async void ChooseProject (object sender, EventArgs e) { var positions = await App.GetGpsPositions (); var gpsPos = new GpsPosition (lastKnownPosition.Latitude, lastKnownPosition.Longitude, 0, App.User.Id.Value); await Navigation.PushAsync (new Projects (gpsPos, positions)); }
public static bool AddGpsPosition(GpsPosition gpsPosition) { bool toAdd = !_gpsPositions.Contains (gpsPosition); if (toAdd) { _gpsPositions.Add (gpsPosition); ISimpleCache _cache = Resolver.Resolve<ISimpleCache>(); _cache.Remove (GpsPositionsKey); _cache.Set(GpsPositionsKey, _gpsPositions); RestAPI.SetGpsPositionsWithProject (gpsPosition); } return toAdd; }