public async ThreadingTask AddsTheCreatedTimeEntryToTheList()
            {
                await ViewModel.Initialize();

                var newTimeEntry = NewTimeEntry.With((long)TimeSpan.FromHours(1).TotalSeconds);

                TimeEntryCreatedSubject.OnNext(newTimeEntry);

                ViewModel.TimeEntries.Any(c => c.Any(te => te.Id == 21)).Should().BeTrue();
                ViewModel.TimeEntries.Aggregate(0, (acc, te) => acc + te.Count).Should().Be(InitialAmountOfTimeEntries + 1);
            }
Example #2
0
            //This can happen, for example, if the time entry was just stopped
            public async ThreadingTask AddsTheTimeEntryIfItWasNotAddedPreviously()
            {
                await ViewModel.Initialize();

                var newTimeEntry = NewTimeEntry.With((long)TimeSpan.FromHours(1).TotalSeconds);

                TimeEntryUpdatedSubject.OnNext((newTimeEntry.Id, newTimeEntry));

                ViewModel.TimeEntries.Any(c => c.Any(te => te.Id == 21)).Should().BeTrue();
                ViewModel.TimeEntries.Aggregate(0, (acc, te) => acc + te.Count).Should().Be(InitialAmountOfTimeEntries + 1);
            }
Example #3
0
                public async ThreadingTask IgnoresTheTimeEntryIfItWasDeleted()
                {
                    await ViewModel.Initialize();

                    var newTimeEntry = TimeEntry.DirtyDeleted(NewTimeEntry.With(DateTimeOffset.UtcNow.AddHours(1)));

                    TimeEntryCreatedSubject.OnNext(NewTimeEntry);

                    ViewModel.TimeEntries.Any(c => c.Any(te => te.Id == 21)).Should().BeFalse();
                    ViewModel.TimeEntries.Aggregate(0, (acc, te) => acc + te.Count).Should().Be(InitialAmountOfTimeEntries);
                }
Example #4
0
                public async ThreadingTask AddsTheCreatedTimeEntryToTheList()
                {
                    await ViewModel.Initialize();

                    var newTimeEntry = NewTimeEntry.With(DateTimeOffset.UtcNow.AddHours(1));

                    TimeEntryCreatedSubject.OnNext(newTimeEntry);

                    ViewModel.TimeEntries.Any(c => c.Any(te => te.Id == 21)).Should().BeTrue();
                    ViewModel.TimeEntries.Aggregate(0, (acc, te) => acc + te.Count).Should().Be(InitialAmountOfTimeEntries + 1);
                }
Example #5
0
                //This can happen, for example, if the time entry was just stopped
                public async ThreadingTask AddsTheTimeEntryIfItWasNotAddedPreviously()
                {
                    var stopDate = DateTimeOffset.UtcNow.AddHours(1);
                    await ViewModel.Initialize();

                    var newTimeEntry = NewTimeEntry.With(stopDate);

                    TimeEntryUpdatedSubject.OnNext((newTimeEntry.Id, newTimeEntry));

                    ViewModel.TimeEntries.Any(c => c.Any(te => te.Id == 21)).Should().BeTrue();
                    ViewModel.TimeEntries.Aggregate(0, (acc, te) => acc + te.Count).Should().Be(InitialAmountOfTimeEntries + 1);
                }
Example #6
0
        public async Task <bool> UpdateTimeEntry(int id, NewTimeEntry pTimeEntry)
        {
            try
            {
                var    requestring = "/time_entries/" + id + ".json";
                string postdata    = JsonConvert.SerializeObject(pTimeEntry);
                var    data        = await client.HttpClient.PutAsync(requestring, new StringContent("{\"time-entry\": " + postdata + "}", Encoding.UTF8));

                if (data.StatusCode == HttpStatusCode.Created || data.StatusCode == HttpStatusCode.OK)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception("Error processing Teamwork API Request: ", ex);
            }
        }