public static async Task<EditTimeEntryGroupViewModel> Init (List<string> timeEntryIds)
 {
     var timeEntryList = await GetTimeEntryDataList (timeEntryIds);
     var model = new TimeEntryModel (timeEntryList.Last ());
     await model.LoadAsync ();
     return new EditTimeEntryGroupViewModel (model, timeEntryList);
 }
Esempio n. 2
0
        private async void CreateModelFromIntent()
        {
            var extras = Intent.Extras;

            if (extras == null)
            {
                return;
            }

            var  extraIdStr = extras.GetString(ExtraTimeEntryId);
            Guid extraId;

            if (!Guid.TryParse(extraIdStr, out extraId))
            {
                return;
            }

            model = new TimeEntryModel(extraId);
            model.PropertyChanged += OnPropertyChange;

            // Ensure that the model exists
            await model.LoadAsync();

            if (model.Workspace == null || model.Workspace.Id == Guid.Empty)
            {
                Finish();
            }
        }
Esempio n. 3
0
        private async Task StartEntry(Guid id)
        {
            var model = new TimeEntryModel(id);
            await model.LoadAsync();

            await TimeEntryModel.ContinueAsync(model.Data);
        }
        private async void LoadModel()
        {
            await model.LoadAsync();

            if (model.Workspace == null || model.Workspace.Id == Guid.Empty)
            {
                Dismiss();
            }
        }
Esempio n. 5
0
        public static async Task <EditTimeEntryGroupViewModel> Init(List <string> timeEntryIds)
        {
            var timeEntryList = await GetTimeEntryDataList(timeEntryIds);

            var model = new TimeEntryModel(timeEntryList.Last());
            await model.LoadAsync();

            return(new EditTimeEntryGroupViewModel(model, timeEntryList));
        }
 private async void LoadData ()
 {
     model = new TimeEntryModel (TimeEntryId);
     await model.LoadAsync ();
     if (model.Workspace == null || model.Workspace.Id == Guid.Empty) {
         Dismiss ();
     } else {
         modelLoaded = true;
     }
 }
 private async void LoadData ()
 {
     model = new TimeEntryModel (TimeEntryId);
     await model.LoadAsync ();
     if (model.Workspace == null || model.Workspace.Id == Guid.Empty) {
         // Invalid model, do nothing.
     } else {
         modelLoaded = true;
     }
 }
Esempio n. 8
0
        private async void LoadData()
        {
            model = new TimeEntryModel(TimeEntryId);
            await model.LoadAsync();

            if (model.Workspace == null || model.Workspace.Id == Guid.Empty)
            {
                // Invalid model, do nothing.
            }
            else
            {
                modelLoaded = true;
            }
        }
Esempio n. 9
0
        private async void LoadData()
        {
            model = new TimeEntryModel(TimeEntryId);
            await model.LoadAsync();

            if (model.Workspace == null || model.Workspace.Id == Guid.Empty)
            {
                Dismiss();
            }
            else
            {
                modelLoaded = true;
            }
        }
Esempio n. 10
0
        private async void LoadData()
        {
            workspace = new WorkspaceModel(WorkspaceId);
            if (TimeEntryId != Guid.Empty)
            {
                timeEntry = new TimeEntryModel(TimeEntryId);
                await Task.WhenAll(workspace.LoadAsync(), timeEntry.LoadAsync());
            }
            else
            {
                await workspace.LoadAsync();
            }

            modelsLoaded = true;
            ValidateTagName();
        }
Esempio n. 11
0
        private async void LoadData()
        {
            timeEntry = new TimeEntryModel(TimeEntryId);
            workspace = new WorkspaceModel(WorkspaceId);
            await Task.WhenAll(timeEntry.LoadAsync(), workspace.LoadAsync());

            if (timeEntry.Workspace == null || timeEntry.Workspace.Id == Guid.Empty)
            {
                // TODO: Better logic to determine if the models are actually non-existent
                Dismiss();
            }
            else
            {
                modelsLoaded = true;
            }
        }
        public static async Task<EditTimeEntryViewModel> Init (Guid timeEntryId)
        {
            var model = new TimeEntryModel (timeEntryId);
            await model.LoadAsync ();

            var tagsView = await TimeEntryTagCollectionView.Init (timeEntryId);
            var tagList = tagsView.Data.ToList ();

            // If the entry is new, setup it a bit.
            if (model.State == TimeEntryState.New) {
                model.StartTime = Time.UtcNow.AddMinutes (-5);
                model.StopTime = Time.UtcNow;
                tagList = await GetDefaultTagList (model.Workspace.Id);
            }

            return new EditTimeEntryViewModel (model, tagList);
        }
Esempio n. 13
0
        public static async Task <List <SimpleTimeEntryData> > GetTimeEntryData()
        {
            var store  = ServiceContainer.Resolve <IDataStore> ();
            var userId = ServiceContainer.Resolve <AuthManager> ().GetUserId();

            var entries = await store.Table <TimeEntryData>()
                          .Where(r => r.State != TimeEntryState.New &&
                                 r.DeletedAt == null &&
                                 r.UserId == userId)
                          .OrderByDescending(r => r.StartTime)
                          .ToListAsync();

            var uniqueEntries = entries.GroupBy(x => new { x.ProjectId, x.Description })
                                .Select(grp => grp.First())
                                .Take(itemCount)
                                .ToList();

            var simpleEntries = new List <SimpleTimeEntryData> ();

            foreach (var entry in uniqueEntries)
            {
                var model = new TimeEntryModel(entry);
                await model.LoadAsync();

                int    color       = 0;
                String projectName = "";
                if (model.Project != null)
                {
                    color       = model.Project.Color;
                    projectName = model.Project.Name;
                }
                var colorString = ProjectModel.HexColors [color % ProjectModel.HexColors.Length];

                simpleEntries.Add(
                    new SimpleTimeEntryData {
                    Id           = entry.Id,
                    IsRunning    = entry.State == TimeEntryState.Running,
                    Description  = entry.Description,
                    Project      = projectName,
                    ProjectColor = colorString,
                    StartTime    = entry.StartTime,
                    StopTime     = entry.StopTime ?? DateTime.MinValue
                });
            }
            return(simpleEntries);
        }
Esempio n. 14
0
        public static async Task<List<SimpleTimeEntryData>> GetTimeEntryData ()
        {
            var store = ServiceContainer.Resolve<IDataStore> ();
            var userId = ServiceContainer.Resolve<AuthManager> ().GetUserId ();

            var entries = await store.Table<TimeEntryData>()
                          .Where (r => r.State != TimeEntryState.New
                                  && r.DeletedAt == null
                                  && r.UserId == userId)
                          .OrderByDescending (r => r.StartTime)
                          .ToListAsync();

            var uniqueEntries = entries.GroupBy (x  => new {x.ProjectId, x.Description })
            .Select (grp => grp.First())
            .Take (itemCount)
            .ToList();

            var simpleEntries = new List<SimpleTimeEntryData> ();
            foreach (var entry in uniqueEntries) {
                var model = new TimeEntryModel (entry);
                await model.LoadAsync();

                int color = 0;
                String projectName = "";
                if (model.Project != null) {
                    color = model.Project.Color;
                    projectName = model.Project.Name;
                }
                var colorString = ProjectModel.HexColors [color % ProjectModel.HexColors.Length];

                simpleEntries.Add (
                new SimpleTimeEntryData {
                    Id = entry.Id,
                    IsRunning = entry.State == TimeEntryState.Running,
                    Description = entry.Description,
                    Project = projectName,
                    ProjectColor = colorString,
                    StartTime = entry.StartTime,
                    StopTime = entry.StopTime ?? DateTime.MinValue
                });
            }
            return simpleEntries;
        }
Esempio n. 15
0
        private async void CreateModelFromIntent ()
        {
            var extras = Intent.Extras;
            if (extras == null)
                return;

            var extraIdStr = extras.GetString (ExtraTimeEntryId);
            Guid extraId;
            if (!Guid.TryParse (extraIdStr, out extraId))
                return;

            model = new TimeEntryModel (extraId);

            // Ensure that the model exists
            await model.LoadAsync ();
            if (model.Workspace == null || model.Workspace.Id == Guid.Empty) {
                Finish ();
            }
        }
Esempio n. 16
0
        public static async Task<EditTimeEntryViewModel> Init (Guid timeEntryId)
        {
            TimeEntryModel model;
            List<TagData> tagList;

            if (timeEntryId == Guid.Empty) {
                model = new TimeEntryModel (TimeEntryModel.GetDraft ());
                model.StartTime = Time.UtcNow.AddMinutes (-5);
                model.StopTime = Time.UtcNow;
                model.State = TimeEntryState.Finished;
                tagList = await GetDefaultTagList (model.Workspace.Id);
            } else {
                model = new TimeEntryModel (timeEntryId);
                await model.LoadAsync ();
                var tagsView = await TimeEntryTagCollectionView.Init (timeEntryId);
                tagList = tagsView.Data.ToList ();
            }

            return new EditTimeEntryViewModel (model, tagList);
        }
Esempio n. 17
0
 private async Task StartEntry (Guid id)
 {
     var model = new TimeEntryModel (id);
     await model.LoadAsync();
     await TimeEntryModel.ContinueAsync (model.Data);
 }
 private async Task SyncModel ()
 {
     var data = timeEntryManager.Active;
     if (data != null) {
         model = new TimeEntryModel (data);
         await model.LoadAsync ();
         UpdateView ();
     }
 }
        private async void LoadData ()
        {
            timeEntry = new TimeEntryModel (TimeEntryId);
            workspace = new WorkspaceModel (WorkspaceId);
            await Task.WhenAll (timeEntry.LoadAsync (), workspace.LoadAsync ());

            if (timeEntry.Workspace == null || timeEntry.Workspace.Id == Guid.Empty) {
                // TODO: Better logic to determine if the models are actually non-existent
                Dismiss ();
            } else {
                modelsLoaded = true;
            }
        }
Esempio n. 20
0
 private void UpdateView (bool isRunning, TimeEntryData data)
 {
     ServiceContainer.Resolve<IPlatformUtils> ().DispatchOnUIThread (async () => {
         // Check if an entry is running.
         if (isRunning) {
             var model = new TimeEntryModel (data);
             await model.LoadAsync ();
             Description = model.Description;
             ProjectName = model.Project != null ? model.Project.Name : string.Empty;
             IsTimeEntryRunning = true;
             durationTimer.Start ();
         } else {
             Description = string.Empty;
             ProjectName = string.Empty;
             IsTimeEntryRunning = false;
             durationTimer.Stop ();
             Duration = TimeSpan.FromSeconds (0).ToString ().Substring (0, 8);
         }
     });
 }