internal Draft(ConfigurationId id, Data data, Author author) { Id = id; Data = data; Author = author; CreationDate = Date.FromDateTime(DateTime.UtcNow); }
public Result GoLive(Guid id, string author) { Live live = null; var configurationId = ConfigurationId.FromGuid(id); var authorResult = Author.FromString(author); if (authorResult.IsFailure) { return(Result.Failure(authorResult.Message)); } if (_repository.DraftExists(configurationId).IsSuccess) { var draftResult = _repository.GetDraft(configurationId); live = draftResult.Value.GoLive(authorResult.Value); } if (_repository.PlannedExists(configurationId).IsSuccess) { var plannedResult = _repository.GetPlanned(configurationId); live = plannedResult.Value.GoLive(authorResult.Value); } else { return(Result.Failure("There is no draft or planned configuration with id: {id}")); } return(_repository.Save(live)); }
internal Draft(ConfigurationId id, Data data, Author author, Date creationDate) { Id = id; Data = data; Author = author; CreationDate = creationDate; }
internal Archive(ConfigurationId id, Data data, Author author) { Id = id; Data = data; Author = author; CreationDate = Date.Now(); }
internal Planned(ConfigurationId id, Data data, Author author, Date creationDate, Date whenGoLive) { Id = id; Data = data; Author = author; CreationDate = creationDate; WhenGoLive = whenGoLive; }
internal Planned(ConfigurationId id, Data data, Author author, Date goLive) { Id = id; Data = data; Author = author; WhenGoLive = goLive; CreationDate = Date.Now(); }
private void AssertDraft(ConfigurationId draftId) { var draftFromRepository = _repository.GetDraft(draftId); draftFromRepository.HasValue.Should().BeTrue(); draftFromRepository.Value.Data.AsString().Should().Be(someData); draftFromRepository.Value.Author.AsString().Should().Be(draftAuthor); draftFromRepository.Value.CreationDate.ShouldBe(DateTime.UtcNow); }
private void AssertLive(ConfigurationId liveId) { var live = _repository.GetLive(liveId); live.HasValue.Should().BeTrue(); live.Value.Data.AsString().Should().Be(someData); live.Value.Author.AsString().Should().Be(liveAuthor); live.Value.CreationDate.ShouldBe(DateTime.UtcNow); }
private void AssertArchive(ConfigurationId archiveId) { var archived = _repository.GetArchived(archiveId); archived.HasValue.Should().BeTrue(); archived.Value.Data.AsString().Should().Be(someData); archived.Value.Author.AsString().Should().Be(archiveAuthor); archived.Value.CreationDate.ShouldBe(DateTime.UtcNow); }
public Maybe <Archive> GetArchived(ConfigurationId id) { var dataRow = _data.FirstOrDefault(d => d.Id == id.AsGuid() && d.Status == ConfigStatus.Archived); if (dataRow == null) { return(Maybe <Archive> .None); } return(ArchiveFactory.Create(dataRow.Id, dataRow.Data, dataRow.ArchivedAuthor, dataRow.ArchiveCreation)); }
private void AssertPlanned(ConfigurationId plannedId) { var planned = _repository.GetPlanned(plannedId); planned.HasValue.Should().BeTrue(); planned.Value.Data.AsString().Should().Be(someData); planned.Value.Author.AsString().Should().Be(plannedAuthor); planned.Value.CreationDate.ShouldBe(DateTime.UtcNow); planned.Value.WhenGoLive.ShouldBe(goLive); }
public void add_skillset(ConfigurationId skillset_id) { if (configuration.SkillSets.Value.Any(item => item.Id == skillset_id.Id)) { return; } configuration.PrepareForEdit(); configuration.SkillSets.Value.Add(skillset_id); configuration.Commit(); }
public Maybe <Draft> GetDraft(ConfigurationId id) { var dataRow = _data.FirstOrDefault(d => d.Id == id.AsGuid() && d.Status == ConfigStatus.Draft); if (dataRow == null) { return(Maybe <Draft> .None); } return(DraftFactory.Create(dataRow.Id, dataRow.Data, dataRow.DraftAuthor, dataRow.DraftCreation)); }
public Maybe <Planned> GetPlanned(ConfigurationId id) { var dataRow = _data.FirstOrDefault(d => d.Id == id.AsGuid() && d.Status == ConfigStatus.Planned); if (dataRow == null) { return(Maybe <Planned> .None); } return(PlannedFactory.Create(dataRow.Id, dataRow.Data, dataRow.PlannedAuthor, dataRow.PlannedCreation, dataRow.WhenGoLive)); }
public Result Archive(Guid id, string author) { var configurationId = ConfigurationId.FromGuid(id); var authorResult = Author.FromString(author); var liveResult = _repository.GetLive(configurationId); return(Result.Combine(authorResult, (Result <Live>)liveResult) .OnSuccess(() => liveResult.Value.Archive(authorResult.Value) .OnSuccess(result => _repository.Save(result.Value)) )); }
private void AssertRawData(ConfigurationId archiveId) { var goLiveDate = Date.FromDateTime(goLive); var dataRow = _repository.Get(archiveId.AsGuid()); dataRow.Status.Should().Be(ConfigStatus.Archived); dataRow.DraftAuthor.Should().Be(draftAuthor); dataRow.PlannedAuthor.Should().Be(plannedAuthor); dataRow.LiveAuthor.Should().Be(liveAuthor); dataRow.WhenGoLive.Should().Be(goLiveDate.AsDateTime()); dataRow.ArchivedAuthor.Should().Be(archiveAuthor); }
/// <summary> /// Creates a draft objects based on values stored in the DB. /// </summary> internal static Result <Draft> Create(Guid id, string data, string author, DateTime creationDate) { var configurationId = ConfigurationId.FromGuid(id); var draftCreationDate = Date.FromDateTime(creationDate); var draftDataResult = Data.FromString(data); var draftAuthorResult = Author.FromString(author); Result.Combine(draftDataResult, draftAuthorResult) .OnFailure((r) => throw new ArgumentOutOfRangeException(r.Message)); return(Result.Success <Draft>(new Draft(configurationId, draftDataResult.Value, draftAuthorResult.Value, draftCreationDate))); }
internal static Result <Archive> Create(Guid id, string data, string author, DateTime creationDateTime) { var idValue = ConfigurationId.FromGuid(id); var creationDate = Date.FromDateTime(creationDateTime); var dataResult = Data.FromString(data); var authorResult = Author.FromString(author); Result.Combine(dataResult, authorResult) .OnFailure((r) => throw new ArgumentOutOfRangeException(r.Message)); return(Result.Success <Archive>(new Archive(idValue, dataResult.Value, authorResult.Value, creationDate))); }
public Result Schedule(Guid id, string author, DateTime whenGoLive) { var authorResult = Author.FromString(author); var configurationId = ConfigurationId.FromGuid(id); var whenGoLiveValue = Date.FromDateTime(whenGoLive); var draft = _repository.GetDraft(configurationId); return(Result.Combine(authorResult, (Result <Draft>)draft) .OnSuccess(() => draft.Value.Schedule(authorResult.Value, whenGoLiveValue) .OnSuccess(result => _repository.Save(result.Value)) )); }
/// <summary> /// This is the right way our system should creates draft instances. /// </summary> public static Result <Draft> Create(string data, string author) { var configurationId = ConfigurationId.New(); var draftDataResult = Data.FromString(data); var draftAuthorResult = Author.FromString(author); var combinedResult = Result.Combine(draftDataResult, draftAuthorResult); if (combinedResult.IsFailure) { return(Result.Failure <Draft>(combinedResult.Message)); } return(Result.Success <Draft>(new Draft(configurationId, draftDataResult.Value, draftAuthorResult.Value))); }
public static ContactList find(ConfigurationId id) { return find(id.Id); }
public static Workgroup find(ConfigurationId id, bool resolve_members = true) { return(find(id.Id, resolve_members)); }
public Result DraftExists(ConfigurationId id) { return(_data.Any(d => d.Id == id.AsGuid() && d.Status == ConfigStatus.Draft) ? Result.Success() : Result.Failure($"There is no draft with id: {id}")); }
public Result PlannedExists(ConfigurationId id) { return(_data.Any(d => d.Id == id.AsGuid() && d.Status == ConfigStatus.Planned) ? Result.Success() : Result.Failure($"There is no planned with id {id}")); }
public void add_skillset(ConfigurationId skillset_id) { if (configuration.SkillSets.Value.Any(item => item.Id == skillset_id.Id)) return; configuration.PrepareForEdit(); configuration.SkillSets.Value.Add(skillset_id); configuration.Commit(); }
public static Campaign find(ConfigurationId id, bool resolve_members = true) { return find(id.Id, resolve_members); }
public static PolicySet find(ConfigurationId id) { return find(id.Id); }
public static Skill find(ConfigurationId id) { return(find(id.Id)); }
public static SkillSet find(ConfigurationId id) { return find(id.Id); }
public static Agent find(ConfigurationId id, List <UserConfiguration.Property> properties = null) { return(find(id.Id, properties)); }
public static PolicySet find(ConfigurationId id) { return(find(id.Id)); }
public static Campaign find(ConfigurationId id, bool resolve_members = true) { return(find(id.Id, resolve_members)); }
public static ContactList find(ConfigurationId id) { return(find(id.Id)); }
public static Workgroup find(ConfigurationId id, bool resolve_members = true) { return find(id.Id, resolve_members); }
public static Agent find(ConfigurationId id, List<UserConfiguration.Property> properties = null) { return find(id.Id, properties); }