コード例 #1
0
ファイル: Job.cs プロジェクト: tedmax100/PracticalDDD
        private void Publish(JobView job)
        {
            using (var pipeStream = new NamedPipeClientStream("EventSourcingSample"))
            {
                pipeStream.Connect();

                using (var sw = new StreamWriter(pipeStream))
                {
                    sw.AutoFlush = true;
                    sw.WriteLine(JsonConvert.SerializeObject(job, Formatting.Indented));
                }
            }
        }
コード例 #2
0
ファイル: Job.cs プロジェクト: tedmax100/PracticalDDD
        public void Execute(JobCreated @event)
        {
            Printer.Print("Updating JobView in effect of JobCreated event", ConsoleColor.Magenta);

            var customerRepository = new MyRepository <Customer>();
            var customer           = customerRepository.Fetch(@event.CustomerId);

            var jobView = new JobView
            {
                Id           = @event.JobId,
                CustomerName = customer.Name.ToString(),
                Location     = @event.Location
            };

            var jobViewRepository = new MyRepository <JobView>();

            jobViewRepository.Add(jobView);

            Publish(jobView);
        }