public static WorkEntry Create(TogglEntry entry) { if (entry == null) { throw new ArgumentException("Entry cannot be null", nameof(entry)); } if (string.IsNullOrEmpty(entry.At)) { throw new ArgumentException("Entry.At cannot be null", nameof(entry.At)); } if (string.IsNullOrEmpty(entry.Start)) { throw new ArgumentException("Entry.Start cannot be null", nameof(entry.Start)); } WorkEntry wEntry = null; if (JiraInfo.IsMatch(entry.Description ?? string.Empty)) { try { wEntry = new WorkEntry(entry); } catch (FormatException fe) { Logger.Error("Unable to create work entry from Toggl entry", fe); } } return(wEntry); }
private WorkEntry(TogglEntry entry) { Match info = JiraInfo.Match(entry.Description); TogglId = entry.ID; IssueId = info.Groups["issue"].Value; Comment = info.Groups["comment"].Value; Start = DateTime.Parse(entry.Start); Updated = DateTime.Parse(entry.At); Duration = entry.Duration; }