/// <summary> /// Clock a user into a jobcode, on a timesheet. /// </summary> /// <returns>A tuple of the user and timesheet.</returns> private (User, Timesheet) ClockAUserIntoATimesheet() { // Get the user id var userFilter = new UserFilter { UserNames = new[] { "bobsmith" } }; IList <User> users = this.apiClient.GetUsers(userFilter).Item1; User user = users.First(); // Now get the jobcode id. var jobcodeFilter = new JobcodeFilter { Name = "TestJobcode3" }; IList <Jobcode> jobcodes = this.apiClient.GetJobcodes(jobcodeFilter).Item1; Jobcode jobcode = jobcodes.First(); // Now clock the user into the jobcode. Note that active (i.e. "on-the-clock") timesheets // are created with an End time of DateTimeOffset.MinValue. The dedicated constructor // we're using here does that for you automatically. var timesheetToCreate = new Timesheet(user.Id, jobcode.Id, DateTimeOffset.Now); var createdTimesheet = this.apiClient.CreateTimesheet(timesheetToCreate).Item1; return(user, createdTimesheet); }
/// <summary> /// Asynchronously Create Jobcodes. /// </summary> /// <remarks> /// Add a single jobcode to your company. /// </remarks> /// <param name="jobcode"> /// The <see cref="Jobcode"/> object to be created. /// </param> /// <returns> /// The <see cref="Jobcode"/> object that was created, along with /// an output instance of the <see cref="ResultsMeta"/> class containing additional data. /// </returns> public async Task <(Jobcode, ResultsMeta)> CreateJobcodeAsync( Jobcode jobcode) { (IList <Jobcode> jobcodes, ResultsMeta resultsMeta) = await CreateJobcodesAsync(new[] { jobcode }, default).ConfigureAwait(false); return(jobcodes.FirstOrDefault(), resultsMeta); }
/// <summary> /// Update Jobcodes. /// </summary> /// <remarks> /// Edit a single jobcode in your company. /// </remarks> /// <param name="jobcode"> /// The <see cref="Jobcode"/> object to be updated. /// </param> /// <returns> /// The <see cref="Jobcode"/> object that was updated, along with /// an output instance of the <see cref="ResultsMeta"/> class containing additional data. /// </returns> public (Jobcode, ResultsMeta) UpdateJobcode(Jobcode jobcode) { (IList <Jobcode> jobcodes, ResultsMeta resultsMeta) = UpdateJobcodes(new[] { jobcode }); return(jobcodes.FirstOrDefault(), resultsMeta); }
/// <summary> /// Asynchronously Update Jobcodes, with support for cancellation. /// </summary> /// <remarks> /// Edit a single jobcode in your company. /// </remarks> /// <param name="jobcode"> /// The <see cref="Jobcode"/> object to be updated. /// </param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns> /// The <see cref="Jobcode"/> object that was updated, along with /// an output instance of the <see cref="ResultsMeta"/> class containing additional data. /// </returns> public async Task <(Jobcode, ResultsMeta)> UpdateJobcodeAsync( Jobcode jobcode, CancellationToken cancellationToken) { (IList <Jobcode> jobcodes, ResultsMeta resultsMeta) = await UpdateJobcodesAsync(new[] { jobcode }, cancellationToken).ConfigureAwait(false); return(jobcodes.FirstOrDefault(), resultsMeta); }