예제 #1
0
        public void Create(PerfomanceDto request)
        {
            using (var context = mDbContextFactory.CreateContext())
            {
                var perfomance = new Perfomance
                {
                    Id=Guid.NewGuid(),
                    Name = request.Name,
                    Description = request.Description
                };

                if (request.PlayPeriods != null && request.PlayPeriods.Any())
                {
                    foreach (var playPeriodDto in request.PlayPeriods)
                    {
                        var playPeriod = new PlayPeriod
                        {
                            Id = Guid.NewGuid(),
                            StartDate = playPeriodDto.StartDate,
                            EndDate = playPeriodDto.EndDate,
                            TicketsCapacity = playPeriodDto.TicketsCapacity
                        };

                        perfomance.PlayPeriods.Add(playPeriod);
                    }
                }
                

                context.Set<Perfomance>().Add(perfomance);
                context.SaveChanges();
            }
        }
예제 #2
0
 public void ExecuteStep(PerfomanceDto request)
 {
     var tickets = mTicketsQueries.GetPlayperiodsTickets(request.PlayPeriods.ToList());
     foreach (var ticketDto in tickets)
     {
         var message = String.Format("Дата билета была изменена. Новая дата начала {0}, новая дата конца {1}",
             ticketDto.TicketStartDate, ticketDto.TicketEndDate);
         mEmailSender.SendEmail(ticketDto.Email, message);
     }
 }
예제 #3
0
        public void Update(PerfomanceDto request)
        {
            using (var context = mDbContextFactory.CreateContext())
            {
                var currentPerfomance =
                    context.Set<Perfomance>().Include("PlayPeriods").FirstOrDefault(x => x.Id == request.Id);

                if (currentPerfomance == null)
                {
                    throw new ApplicationException("Постановка не найдена");
                }

                currentPerfomance.Name = request.Name;
                currentPerfomance.Description = request.Description;

                foreach (var playPeriodDto in request.PlayPeriods)
                {
                    var currentPlayPeriod = currentPerfomance.PlayPeriods.FirstOrDefault(x => x.Id == playPeriodDto.Id);
                    if (currentPlayPeriod == null)
                    {
                        var playPeriod = new PlayPeriod
                        {
                            Id = Guid.NewGuid(),
                            StartDate = playPeriodDto.StartDate,
                            EndDate = playPeriodDto.EndDate,
                            TicketsCapacity = playPeriodDto.TicketsCapacity
                        };

                        currentPerfomance.PlayPeriods.Add(playPeriod);
                        continue;
                    }

                    currentPlayPeriod.StartDate = playPeriodDto.StartDate;
                    currentPlayPeriod.EndDate = playPeriodDto.EndDate;
                    currentPlayPeriod.TicketsCapacity = playPeriodDto.TicketsCapacity;
                }

                context.SaveChanges();
            }
        }
 public void ExecuteStep(PerfomanceDto request)
 {
     mPerfomanceCommands.Update(request);
     mNextStepWorkflow.ExecuteStep(request);
 }
 public ActionResult Update(PerfomanceDto request)
 {
     mPerfomanceWorkflow.ExecuteStep(request);
     return Json("success");
 }
 public ActionResult Create(PerfomanceDto request)
 {
     mPerfomanceCommands.Create(request);
     
     return Json("success");
 }