コード例 #1
0
        public async Task AddAsync(AppointmentAggregate appointmentAggregate)
        {
            using var trans = await db.Database.BeginTransactionAsync();

            await db.Slots.AddAsync(appointmentAggregate.Slot);

            await db.Appointments.AddRangeAsync(appointmentAggregate.Appointments);

            await db.SaveChangesAsync();

            await trans.CommitAsync();
        }
コード例 #2
0
        public async Task <OperationResult> CreateAppointmentSlotAsync(LocalDateTime from, Period duration, int countOfSlot)
        {
            var aggregates = await SearchAppointmentsByDateAsync(from.Date);

            if (aggregates.AllSlots.Any(s => s.IsOverlap(from, duration)))
            {
                return(OperationResult.Fail("予約枠が重複しています。"));
            }
            var aggregate = new AppointmentAggregate(from, duration, countOfSlot);
            await _repository.AddAsync(aggregate);

            return(CreateAppointmentSlotResult.Ok(aggregate.Id));
        }
コード例 #3
0
 private ReminderAggregate ConvertToAggregate(reminder reminder, AppointmentAggregate appointmentAggregate)
 {
     return(new ReminderAggregate()
     {
         AppointmentId = appointmentAggregate.Id,
         CustomerName = appointmentAggregate.CustomerName,
         Location = appointmentAggregate.Location,
         ReminderId = reminder.reminderId,
         ReminderDate = reminder.reminderDate,
         StartTime = appointmentAggregate.Start,
         EndTime = appointmentAggregate.End
     });
 }
コード例 #4
0
        public async Task UpdateAsync(AppointmentAggregate appointmentAggregate)
        {
            using var trans = await db.Database.BeginTransactionAsync();

            db.Slots.Update(appointmentAggregate.Slot);
            await db.SaveChangesAsync();

            db.Appointments.RemoveRange(db.Appointments.Where(a => a.AppointmentSlotId == appointmentAggregate.Id));
            await db.SaveChangesAsync();

            await db.Appointments.AddRangeAsync(appointmentAggregate.Appointments);

            await db.SaveChangesAsync();

            await trans.CommitAsync();
        }
コード例 #5
0
ファイル: AppointmentForm.cs プロジェクト: Djcoyer/Software-2
        public void SetAggregate(AppointmentAggregate aggregate)
        {
            var minDate = aggregate.Start < DateTime.Now ? aggregate.Start : DateTime.Now;

            datePicker.MinDate      = minDate;
            appointmentAggregate    = aggregate;
            titleTextBox.Text       = aggregate.Title;
            contactTextBox.Text     = aggregate.Contact;
            customerTextBox.Text    = aggregate.CustomerName;
            locationTextBox.Text    = aggregate.Location;
            UrlTextBox.Text         = aggregate.Url;
            descriptionTextBox.Text = aggregate.Description;
            datePicker.Value        = aggregate.Start;
            startTimePicker.Value   = aggregate.Start;
            endTimePicker.Value     = aggregate.End;
        }
コード例 #6
0
        public void Handle(MakeAppointment command)
        {
            Console.WriteLine("AppointmentCommandHandler Handle " + command.ToString());

            _repository.Find(command.Id).ContinueWith((task) =>
            {
                var appointmentAggregate = task.Result;
                if (appointmentAggregate != null)
                {
                    throw new DuplicatedAggregateException(command.Id, "Appointment");
                }
                else
                {
                    appointmentAggregate = new AppointmentAggregate(command.Id);
                }

                appointmentAggregate.CreateAppointment(command.Appointment);
                var saveTask = _repository.Save(appointmentAggregate, command.Id);
                saveTask.Wait();
            });
        }