PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Atlassian.Jira/Worklog.cs

https://bitbucket.org/miketrebilcock/atlassian.net-sdk
C# | 83 lines | 65 code | 9 blank | 9 comment | 2 complexity | 24a04081dc2b7977edc24e78a6b99731 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Atlassian.Jira.Remote;
  6. namespace Atlassian.Jira
  7. {
  8. /// <summary>
  9. /// Represents the worklog of an issue
  10. /// </summary>
  11. public class Worklog
  12. {
  13. private readonly DateTime? _created;
  14. private readonly string _id;
  15. private readonly long _timeSpentInSeconds;
  16. private readonly DateTime? _updated;
  17. public string Author { get; set; }
  18. public string Comment { get; set; }
  19. public DateTime? StartDate { get; set; }
  20. public string TimeSpent { get; set; }
  21. public string Id
  22. {
  23. get { return _id; }
  24. }
  25. public long TimeSpentInSeconds
  26. {
  27. get { return _timeSpentInSeconds; }
  28. }
  29. public DateTime? CreateDate
  30. {
  31. get { return _created; }
  32. }
  33. public DateTime? UpdateDate
  34. {
  35. get { return _updated; }
  36. }
  37. /// <summary>
  38. /// Creates a new worklog instance
  39. /// </summary>
  40. /// <param name="timeSpent">Specifies a time duration in JIRA duration format, representing the time spent working</param>
  41. /// <param name="startDate">When the work was started</param>
  42. /// <param name="comment">An optional comment to describe the work</param>
  43. public Worklog(string timeSpent, DateTime startDate, string comment = null)
  44. {
  45. this.TimeSpent = timeSpent;
  46. this.StartDate = startDate;
  47. this.Comment = comment;
  48. }
  49. internal Worklog(RemoteWorklog remoteWorklog)
  50. {
  51. if (remoteWorklog != null)
  52. {
  53. this.Author = remoteWorklog.author;
  54. this.Comment = remoteWorklog.comment;
  55. this.StartDate = remoteWorklog.startDate;
  56. this.TimeSpent = remoteWorklog.timeSpent;
  57. _id = remoteWorklog.id;
  58. _created = remoteWorklog.created;
  59. _timeSpentInSeconds = remoteWorklog.timeSpentInSeconds;
  60. _updated = remoteWorklog.updated;
  61. }
  62. }
  63. internal RemoteWorklog ToRemote()
  64. {
  65. return new RemoteWorklog()
  66. {
  67. author = this.Author,
  68. comment = this.Comment,
  69. startDate = this.StartDate,
  70. timeSpent = this.TimeSpent
  71. };
  72. }
  73. }
  74. }