Пример #1
0
 public void Create(AppointmentDto appointment, LightPatientDto patient, GoogleConfiguration config)
 {
     new Creator(this.Session).Create(appointment, patient, config);
 }
Пример #2
0
 /// <summary>
 /// Execute a dummy query to Google Calendar to spin it up.
 /// If an error occured, it is gracefully swallowed and logged.
 /// </summary>
 public void SpinUpGoogle(GoogleConfiguration config)
 {
     new GoogleService(config).SpinUp();
 }
Пример #3
0
 public void Remove(AppointmentDto meeting, LightPatientDto patient, GoogleConfiguration config)
 {
     var entity = this.Session.Get<Appointment>(meeting.Id);
     if (config.IsActive)
     {
         new GoogleService(config).RemoveAppointment(entity);
     }
     this.Remove(meeting, patient);
 }
Пример #4
0
        /// <summary>
        /// Gets the appointments for the specified day and add all the appointments from Google Calendar.
        /// </summary>
        /// <param name="day">The day.</param>
        /// <returns>A list of appointments</returns>
        public IList<AppointmentDto> GetAppointments(DateTime day, GoogleConfiguration config)
        {
            var result = (from a in this.Session.Query<Appointment>()
                          where a.StartTime >= day.Date
                             && a.EndTime <= day.Date.AddDays(1)
                          select a).ToList();

            if (config.IsActive)
            {
                result.AddRange(new GoogleService(config).GetAppointments(day, this.GetGoogleTag()));
            }

            return Mapper.Map<IList<Appointment>, IList<AppointmentDto>>(result);
        }
Пример #5
0
        /// <summary>
        /// Creates the specified appointment and use create it in Google Calendar if the binding is active.
        /// </summary>
        /// <param name="appointment">The appointment.</param>
        /// <param name="patient">The patient.</param>
        /// <param name="config">The config.</param>
        public void Create(AppointmentDto appointment, LightPatientDto patient, GoogleConfiguration config)
        {
            var patientEntity = this.Session.Get<Patient>(patient.Id);
            var meetingEntity = Mapper.Map<AppointmentDto, Appointment>(appointment);

            meetingEntity.GoogleSynchronisationId = (config.IsActive)
                ? Guid.NewGuid() //This id allows to find Google appointments
                : new Guid(); //Empty Guid indicates this appointments is not binded with Google Calendar

            meetingEntity.User = this.Session.Get<User>(meetingEntity.User.Id);

            patientEntity.Appointments.Add(meetingEntity);
            this.Session.SaveOrUpdate(patientEntity);

            if (config.IsActive)
            {
                new GoogleService(config).AddAppointment(meetingEntity);
            }
        }
Пример #6
0
 public GoogleService(GoogleConfiguration config)
 {
     this.UserName = config.UserName;
     this.Password = config.Password;
     this.CalendarUri = config.CalendarUri;
 }