Esempio n. 1
0
		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);
		}
Esempio n. 2
0
        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();
            };
        }
Esempio n. 3
0
		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));
		}
Esempio n. 4
0
		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;
		}