// TODO: WIP public JsonResult GetTimeEntries(TimeEntryRequest req) { return Json(new { f = "rrr" }); }
public static TimeEntryResponse StartClockify(string workspaceId, TimeEntryRequest req) { return(_clockifyService.PostTimeEntry(workspaceId, req)); }
/// <summary> /// Add a new time entry to workspace. If end is not sent in request means that stopwatch mode is active, otherwise time entry is manually added. /// </summary> public Task <IRestResponse <TimeEntryDtoImpl> > CreateTimeEntryAsync(string workspaceId, TimeEntryRequest timeEntryRequest) { if (timeEntryRequest == null) { throw new ArgumentNullException(nameof(timeEntryRequest)); } if (timeEntryRequest.Start == null) { throw new ArgumentNullException(nameof(timeEntryRequest.Start)); } var request = new RestRequest($"workspaces/{workspaceId}/time-entries", Method.POST); request.AddJsonBody(timeEntryRequest); return(_client.ExecutePostAsync <TimeEntryDtoImpl>(request)); }
public async Task FindAllTimeEntriesForProjectAsync_ShouldReturnTimeEntryDtoImplList() { // Create project var projectRequest = new ProjectRequest { Name = "FindAllTimeEntriesForProjectAsync " + Guid.NewGuid(), Color = "#FF00FF" }; var createProject = await _client.CreateProjectAsync(_workspaceId, projectRequest); createProject.IsSuccessful.Should().BeTrue(); createProject.Data.Should().NotBeNull(); ProjectDtoImpl project = createProject.Data; // Create TimeEntries var now = DateTimeOffset.UtcNow; var timeEntry1Request = new TimeEntryRequest { ProjectId = project.Id, Start = now, End = now.AddMinutes(2), Description = "TimeEntry1" }; var addTimeEntry1 = await _client.CreateTimeEntryAsync(_workspaceId, timeEntry1Request); addTimeEntry1.IsSuccessful.Should().BeTrue(); addTimeEntry1.Data.Should().NotBeNull(); TimeEntryDtoImpl timeEntry1 = addTimeEntry1.Data; var timeEntry2Request = new TimeEntryRequest { ProjectId = project.Id, Start = now.AddDays(-1), End = now.AddMinutes(3), Description = "TimeEntry2" }; var addTimeEntry2 = await _client.CreateTimeEntryAsync(_workspaceId, timeEntry2Request); addTimeEntry2.IsSuccessful.Should().BeTrue(); addTimeEntry2.Data.Should().NotBeNull(); TimeEntryDtoImpl timeEntry2 = addTimeEntry2.Data; // Send request var response = await _client.FindAllTimeEntriesForProjectAsync(_workspaceId, projectId : project.Id, start : DateTimeOffset.Now.AddDays(-2), end : DateTimeOffset.Now.AddDays(1)); //response.IsSuccessful.Should().BeTrue(); response.Data.Should().NotBeNull(); List <TimeEntryDtoImpl> responseContent = response.Data as List <TimeEntryDtoImpl>; responseContent.Should().Contain(timeEntry => timeEntry.Id.Equals(timeEntry1.Id)); responseContent.Should().Contain(timeEntry => timeEntry.Id.Equals(timeEntry2.Id)); // Clean up await _client.DeleteTimeEntryAsync(_workspaceId, addTimeEntry1.Data.Id); await _client.DeleteTimeEntryAsync(_workspaceId, addTimeEntry2.Data.Id); var deleteProject = await _client.ArchiveAndDeleteProject(_workspaceId, createProject.Data.Id); deleteProject.IsSuccessful.Should().BeTrue(); }