コード例 #1
0
        private static void CreateAndCountTicket()
        {
            using (var context = new SqLiteTicketsDbContext())
            {
                var ticket = new Ticket
                {
                    Title     = "Title",
                    Details   = "Details",
                    CreatedAt = DateTime.Now
                };

                ticket.AddComment("Some Comment", -1);
                ticket.AddComment("Some Other Comment", -1);

                context.Tickets.Add(ticket);
                context.SaveChanges();
            }

            using (var context = new SqLiteTicketsDbContext())
            {
                var ticket = context.Tickets
                             .Include(t => t.Comments)
                             .FirstOrDefault();

                Assert.That(ticket, Is.Not.Null);
                Assert.That(ticket.Comments.Count, Is.EqualTo(2));

                var ticketCount = context.Tickets.Count();
                Assert.That(ticketCount, Is.EqualTo(1));
            }
        }
コード例 #2
0
        public void Handle(CreateTicketCommentCommand message)
        {
            User   user   = _userRepository.GetByLoginName(message.User);
            Ticket ticket = _ticketRepository.GetByTicketNumber(message.TicketNumber);

            ticket.AddComment(message.Comment, user);
            _ticketRepository.Update(ticket);
        }