public async Task HandleAsync(CreateScheduleSchema command) { var alreadyExists = await _repository.ExistsAsync(command.CinemaId); if (alreadyExists) { throw new ScheduleSchemaAlreadyExistsException(command.CinemaId); } var scheduleSchema = ScheduleSchema.Create(command.Id, command.CinemaId, command.Times.AsScheduleSchemaTimes()); await _repository.AddAsync(scheduleSchema); await _processor.ProcessAsync(scheduleSchema.DomainEvents); }
public static ScheduleSchemaDocument AsDocument(this ScheduleSchema schema) => new ScheduleSchemaDocument { Id = schema.Id, CinemaId = schema.CinemaId, Times = schema.Times?.Select(st => new ScheduleSchemaTimesDocument { AgeRestriction = st.ageRestriction, Times = st.times?.Select(t => new TimeDocument { Hour = t.Hour, Minute = t.Minute }) }), Version = schema.Version };
public ScheduleSchemaAdded(ScheduleSchema schema) { Schema = schema; }
public ScheduleSchemaTimesChanged(ScheduleSchema schema, ScheduleSchemaTimes times) { Schema = schema; Times = times; }