コード例 #1
0
        bool RecordTime(TimeEntry timeEntry, Task task)
        {
            var timeEntryModel = new TimeEntryModel
            {
                Date            = GetCompatibleDate(timeEntry).ToString("O"),
                Notes           = timeEntry.Comment,
                TimeString      = timeEntry.MinutesSpent + "m",
                DurationSeconds = timeEntry.MinutesSpent * 60,
                ProjectId       = timeEntry.Project?.Id,
                TaskId          = task?.Id,
                WorkItems       = new List <string>(), // TODO: add functionality for tracking WorkItems
            };

            var post = new RestRequest
            {
                Resource      = "Time/Save",
                Method        = Method.POST,
                RequestFormat = DataFormat.Json
            };

            post.AddBody(timeEntryModel);

            var result = _api.Execute <TimeEntryModel>(post);

            return(result != null);
        }
コード例 #2
0
        public IEnumerable <Project> GetProjects()
        {
            var request = new RestRequest {
                Resource = "json/Project/List"
            };

            var apiResult = _api.Execute <List <DTO.Project> >(request);

            return(apiResult?.Select(project => new Project
            {
                Id = project.Id.ToString(),
                Name = project.Name,
                Key = project.FromIntegrationId
            }));
        }