コード例 #1
0
        public void CreateTimeEntryWithWorkspaceTest()
        {
            Task <TimeEntry> task = TimeEntry.CreateTimeEntry("New time entry",
                                                              new DateTime(2016, 9, 20, 10, 35, 17), 100, workspaceId: WorkspaceTests.workspaceId);

            task.Wait();
            TimeEntry entry = task.Result;

            Assert.IsNotNull(entry);
            Assert.AreEqual("New time entry", entry.Description);

            // Clean up
            TimeEntry.DeleteEntry(entry.Id).Wait();
        }
コード例 #2
0
        public void CreateTimeEntryWithProjectTest()
        {
            Task <TimeEntry> task = TimeEntry.CreateTimeEntry("New time entry",
                                                              new DateTime(2016, 9, 20, 10, 35, 17), 100, projectId: 33544573);

            task.Wait();
            TimeEntry entry = task.Result;

            Assert.IsNotNull(entry);
            Assert.AreEqual("New time entry", entry.Description);
            Assert.AreEqual(33544573, entry.ProjectId);

            // Clean up
            TimeEntry.DeleteEntry(entry.Id).Wait();
        }
コード例 #3
0
        /// <summary>
        /// Create a new time entry with a predefined start and end time
        /// </summary>
        /// <param name="description"></param>
        /// <param name="projectName"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="tags"></param>
        internal async void CreateTimeEntry(string description, string projectName, DateTime start, DateTime end, List <Tag> tags = null)
        {
            TimeEntry entry;

            try
            {
                int     duration = (int)(end - start).TotalSeconds;
                Project project  = null;
                try
                {
                    project = App.Data.Projects.First(x => x.Name == projectName);
                    entry   = await TimeEntry.CreateTimeEntry(description, start, duration, project.ID);
                }
                catch (Exception)
                {
                    entry = await TimeEntry.CreateTimeEntry(description, start, duration);
                }

                entry.ProjectName = projectName;
                AddTimeEntry(entry);
            }
            catch (Exception) { }
        }