Ejemplo n.º 1
0
        //add an appointment --> create calender entry
        public async Task <int> AddAppointment(Appointment appointment)
        {
            if (appointment.EndDate <= appointment.StartDate)
            {
                throw new RepositoryException(RepositiryExceptionType.BadAppointmentEndDateTime, null);
            }
            var newAppointment = _dbContext.Appointments.Add(appointment).Entity.ID;
            await _dbContext.SaveChangesAsync();

            return(newAppointment);
        }
Ejemplo n.º 2
0
        private Appointment InsertTestAppointment(DateTime startTime, DateTime endTime, string location, string summary)
        {
            Appointment appointment;

            using (var dbContext = new AppointmentsDBContext(_optionsBuilder.Options))
            {
                appointment = dbContext.Appointments.Add(new Appointment()
                {
                    StartDate = startTime,
                    EndDate   = endTime,
                    Location  = location,
                    Summary   = summary
                }).Entity;
                dbContext.SaveChangesAsync();
            }
            return(appointment);
        }