コード例 #1
0
ファイル: Draft.cs プロジェクト: rafalpienkowski/workflow-ddd
 internal Draft(ConfigurationId id, Data data, Author author)
 {
     Id           = id;
     Data         = data;
     Author       = author;
     CreationDate = Date.FromDateTime(DateTime.UtcNow);
 }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: Draft.cs プロジェクト: rafalpienkowski/workflow-ddd
 internal Draft(ConfigurationId id, Data data, Author author, Date creationDate)
 {
     Id           = id;
     Data         = data;
     Author       = author;
     CreationDate = creationDate;
 }
コード例 #4
0
 internal Archive(ConfigurationId id, Data data, Author author)
 {
     Id           = id;
     Data         = data;
     Author       = author;
     CreationDate = Date.Now();
 }
コード例 #5
0
 internal Planned(ConfigurationId id, Data data, Author author, Date creationDate, Date whenGoLive)
 {
     Id           = id;
     Data         = data;
     Author       = author;
     CreationDate = creationDate;
     WhenGoLive   = whenGoLive;
 }
コード例 #6
0
 internal Planned(ConfigurationId id, Data data, Author author, Date goLive)
 {
     Id           = id;
     Data         = data;
     Author       = author;
     WhenGoLive   = goLive;
     CreationDate = Date.Now();
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: Campaign.cs プロジェクト: gildas/DialerNetAPIDemo
 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();
 }
コード例 #13
0
        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));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
        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))
                              ));
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        /// <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)));
        }
コード例 #18
0
        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)));
        }
コード例 #19
0
        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))
                              ));
        }
コード例 #20
0
        /// <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)));
        }
コード例 #21
0
 public static ContactList find(ConfigurationId id)
 {
     return find(id.Id);
 }
コード例 #22
0
ファイル: Workgroup.cs プロジェクト: gildas/DialerNetAPIDemo
 public static Workgroup find(ConfigurationId id, bool resolve_members = true)
 {
     return(find(id.Id, resolve_members));
 }
コード例 #23
0
 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}"));
 }
コード例 #24
0
 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}"));
 }
コード例 #25
0
ファイル: Campaign.cs プロジェクト: gildas/DialerNetAPIDemo
 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();
 }
コード例 #26
0
ファイル: Campaign.cs プロジェクト: gildas/DialerNetAPIDemo
 public static Campaign find(ConfigurationId id, bool resolve_members = true)
 {
     return find(id.Id, resolve_members);
 }
コード例 #27
0
ファイル: PolicySet.cs プロジェクト: gildas/DialerNetAPIDemo
 public static PolicySet find(ConfigurationId id)
 {
     return find(id.Id);
 }
コード例 #28
0
 public static Skill find(ConfigurationId id)
 {
     return(find(id.Id));
 }
コード例 #29
0
ファイル: SkillSet.cs プロジェクト: gildas/DialerNetAPIDemo
 public static SkillSet find(ConfigurationId id)
 {
     return find(id.Id);
 }
コード例 #30
0
 public static Agent find(ConfigurationId id, List <UserConfiguration.Property> properties = null)
 {
     return(find(id.Id, properties));
 }
コード例 #31
0
 public static PolicySet find(ConfigurationId id)
 {
     return(find(id.Id));
 }
コード例 #32
0
ファイル: Campaign.cs プロジェクト: gildas/DialerNetAPIDemo
 public static Campaign find(ConfigurationId id, bool resolve_members = true)
 {
     return(find(id.Id, resolve_members));
 }
コード例 #33
0
 public static ContactList find(ConfigurationId id)
 {
     return(find(id.Id));
 }
コード例 #34
0
ファイル: Workgroup.cs プロジェクト: gildas/DialerNetAPIDemo
 public static Workgroup find(ConfigurationId id, bool resolve_members = true)
 {
     return find(id.Id, resolve_members);
 }
コード例 #35
0
ファイル: Agent.cs プロジェクト: gildas/DialerNetAPIDemo
 public static Agent find(ConfigurationId id, List<UserConfiguration.Property> properties = null)
 {
     return find(id.Id, properties);
 }