public async Task <ITimeEntry> StartTimeEntry(TimeEntry timeEntry) { try { var createdTimeEntry = await togglApi.TimeEntries .Create(timeEntry) .ConfigureAwait(false); SharedStorage.Instance.SetNeedsSync(true); SharedStorage.Instance.AddWidgetTrackingEvent(WidgetTrackingEvent.StartTimer()); return(createdTimeEntry); } catch (Exception e) { SharedStorage.Instance.AddWidgetTrackingEvent(WidgetTrackingEvent.Error(e.Message)); throw; } }
public async Task StopRunningTimeEntry() { try { await togglApi.TimeEntries .GetAll() .ToObservable() .Select(getRunningTimeEntry) .Select(stopTimeEntry) .FirstAsync(); SharedStorage.Instance.SetNeedsSync(true); SharedStorage.Instance.AddWidgetTrackingEvent(WidgetTrackingEvent.StopTimer()); } catch (Exception e) { SharedStorage.Instance.AddWidgetTrackingEvent(WidgetTrackingEvent.Error(e.Message)); throw; } }