protected override Clue MakeClueImpl([NotNull] Project input, Guid accountId) { if (input == null) { throw new ArgumentNullException(nameof(input)); } var clue = _factory.Create(EntityType.Project, input.Id.ToString(), accountId); var data = clue.Data.EntityData; if (!string.IsNullOrWhiteSpace(input.Name)) { data.Name = input.Name; } var vocab = new ProjectVocabulary(); data.Properties[vocab.Name] = input.Name.PrintIfAvailable(); if (input.Campaigns != null) { foreach (var campaignId in input.Campaigns) { if (campaignId != default) { _factory.CreateOutgoingEntityReference(clue, EntityType.Marketing.Campaign, EntityEdgeType.PartOf, input, campaignId.ToString()); } } } if (!data.OutgoingEdges.Any()) { _factory.CreateEntityRootReference(clue, EntityEdgeType.PartOf); } return(clue); }
protected override Clue MakeClueImpl([NotNull] Project input, Guid accountId) { if (input == null) { throw new ArgumentNullException(nameof(input)); } // TODO: Create clue specifying the type of entity it is and ID var clue = _factory.Create(EntityType.Project, input.id.ToString(), accountId); clue.ValidationRuleSupressions.Add(Constants.Validation.Rules.METADATA_002_Uri_MustBeSet); clue.ValidationRuleSupressions.Add(Constants.Validation.Rules.METADATA_003_Author_Name_MustBeSet); // TODO: Populate clue data var data = clue.Data.EntityData; data.Name = input.name; if (!String.IsNullOrEmpty(input.notes)) { data.Description = input.notes; } if (!String.IsNullOrEmpty(input.name)) { data.Name = input.name; } data.Uri = new Uri(string.Format("https://harvestapp.com/projects/{0}", input.id.ToString())); data.CreatedDate = new DateTimeOffset(input.created_at); data.ModifiedDate = new DateTimeOffset(input.updated_at); var vocab = new ProjectVocabulary(); data.Properties[vocab.ClientName] = input.client.name.PrintIfAvailable(); data.Properties[vocab.Notes] = input.notes.PrintIfAvailable(); data.Properties[vocab.BillBy] = input.bill_by.PrintIfAvailable(); data.Properties[vocab.Budget] = input.budget.PrintIfAvailable(); data.Properties[vocab.EndsOn] = input.ends_on.PrintIfAvailable(); data.Properties[vocab.IsBillable] = input.is_billable.PrintIfAvailable(); data.Properties[vocab.StartsOn] = input.starts_on.PrintIfAvailable(); if (input.expense_ids != null) { foreach (var entry in input.expense_ids) { _factory.CreateOutgoingEntityReference(clue, EntityType.Form, EntityEdgeType.Has, entry.ToString(), entry.ToString()); } } if (input.user_assignment_ids != null) { foreach (var entry in input.user_assignment_ids) { _factory.CreateOutgoingEntityReference(clue, EntityType.Task, EntityEdgeType.Has, entry.ToString(), entry.ToString()); } } if (input.time_entry_ids != null) { foreach (var entry in input.time_entry_ids) { _factory.CreateOutgoingEntityReference(clue, EntityType.Form, EntityEdgeType.Has, entry.ToString(), entry.ToString()); } } if (input.expense_ids != null) { foreach (var entry in input.expense_ids) { _factory.CreateOutgoingEntityReference(clue, EntityType.Form, EntityEdgeType.Has, entry.ToString(), entry.ToString()); } } _factory.CreateOutgoingEntityReference(clue, EntityType.Organization, EntityEdgeType.For, input.client?.id.ToString(), input.client?.id.ToString()); return(clue); }