示例#1
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="hours">The hours on the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer CreateDaily(DateTime spentAt, long projectId, long taskId, decimal hours, string notes = null, long? ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes = notes,
                SpentAt = spentAt,
                ProjectId = projectId,
                TaskId = taskId,
                Hours = hours.ToString("f2")
            };

            return CreateDaily(options, ofUser);
        }
示例#2
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="startedAt">The start timestamp of the entry</param>
        /// <param name="endedAt">The end timestamp of the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer CreateDaily(DateTime spentAt, long projectId, long taskId, TimeSpan startedAt, TimeSpan endedAt, string notes = null, long? ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes = notes,
                SpentAt = spentAt,
                ProjectId = projectId,
                TaskId = taskId,
                StartedAt = new DateTime(2000, 1, 1).Add(startedAt).ToString("h:mmtt").ToLower(),
                EndedAt = new DateTime(2000, 1, 1).Add(endedAt).ToString("h:mmtt").ToLower()
            };

            return CreateDaily(options, ofUser);
        }
示例#3
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the entry to update</param>
        /// <param name="options">The options to update</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        internal Timer UpdateDaily(long dayEntryId, DailyOptions options, long? ofUser)
        {
            var request = Request("daily/update/" + dayEntryId, RestSharp.Method.POST);

            if (ofUser != null)
                request.AddParameter("of_user", ofUser.Value);

            request.AddBody(options);

            return Execute<Timer>(request);
        }
示例#4
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the time entry to update</param>
        /// <param name="spentAt">The new date of the entry</param>
        /// <param name="projectId">The new project ID of the entry</param>
        /// <param name="taskId">The new task ID of the entry</param>
        /// <param name="hours">The new hours for the entry</param>
        /// <param name="startedAt">The new start timestamp for the entry</param>
        /// <param name="endedAt">The new end timestamp for the entry</param>
        /// <param name="notes">The new notes for the entry</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        public Timer UpdateDaily(long dayEntryId, DateTime? spentAt = null, long? projectId = null, long? taskId = null, decimal? hours = null, TimeSpan? startedAt = null, TimeSpan? endedAt = null, string notes = null, long? ofUser = null)
        {
            var options = new DailyOptions()
            {
                SpentAt = spentAt,
                ProjectId = projectId,
                TaskId = taskId,
                Notes = notes
            };

            if (hours != null)
                options.Hours = hours.Value.ToString("f2");

            if (startedAt != null)
                options.StartedAt = new DateTime(2000, 1, 1).Add(startedAt.Value).ToString("h:mmtt").ToLower();

            if (endedAt != null)
                options.EndedAt = new DateTime(2000, 1, 1).Add(endedAt.Value).ToString("h:mmtt").ToLower();

            return UpdateDaily(dayEntryId, options, ofUser);
        }
示例#5
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="options">The options for the time entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        internal Timer CreateDaily(DailyOptions options, long? ofUser)
        {
            var request = Request(ofUser != null ? string.Format("daily/add?of_user={0}", ofUser) : "daily/add", RestSharp.Method.POST);

            request.AddBody(options);

            return Execute<Timer>(request);
        }
示例#6
0
        /// <summary>
        /// Starts a new timer for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer StartTimer(DateTime spentAt, long projectId, long taskId, string notes = null, long? ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes = notes,
                SpentAt = spentAt,
                ProjectId = projectId,
                TaskId = taskId,
                Hours = " "
            };

            return CreateDaily(options, ofUser);
        }