Example #1
0
        async Task GetStoreAsync()
        {
            try
            {
                IReadOnlyList <User> users = await User.FindAllAsync();

                User ActiveUser = users[0];
                try
                {
                    AppointmentManagerForUser appointmentManager = AppointmentManager.GetForUser(ActiveUser);
                    appointmentStore = await appointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
                }
                catch (Exception ex)
                {
                    appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
                }

                if (appointmentStore == null)
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #2
0
        public static async Task <String> AddToCalendar(DJListing listing, DateTime startTime, TimeSpan duration, bool allDay, TimeSpan reminder)
        {
            var appointment   = BuildAppointment(listing, startTime, duration, allDay, reminder);
            var appointmentId = await AppointmentManager.ShowEditNewAppointmentAsync(appointment);

            return(appointmentId);
        }
Example #3
0
        public async Task <CreateVisitStep2ViewModel> CreateVisitStepTwo(CreateVisitViewModel model, CancellationToken cancellationToken)
        {
            var doctor = await _doctorsRepository.GetAsync(model.DoctorName, cancellationToken).ConfigureAwait(false);

            var doctorsAppointments = await _appointmentsRepository.ListAsync(cancellationToken).ConfigureAwait(false);

            var doctorsAppointmentsByDate = doctorsAppointments.Where(a =>
                                                                      a.Doctor.Name == model.DoctorName && a.StartDateTime.Year == model.StartDateTime.Year &&
                                                                      a.StartDateTime.Month == model.StartDateTime.Month && a.StartDateTime.Day == model.StartDateTime.Day);

            var dates = AppointmentManager.GetAvailableTimes(model.StartDateTime);

            foreach (var date in doctorsAppointmentsByDate)
            {
                dates.RemoveAll(dateTime => dateTime.TimeOfDay == date.StartDateTime.TimeOfDay);
            }

            return(new CreateVisitStep2ViewModel
            {
                Date = dates,
                Doctor = doctor,
                DoctorName = model.DoctorName,
                StartDateTime = model.StartDateTime,
                Description = model.Description
            });
        }
Example #4
0
        public void NotReturnMidDayTimes()
        {
            var actual           = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var hasAnyMidDayHour = actual.Any(t => t.Hour == 12);

            hasAnyMidDayHour.Should().BeFalse();
        }
Example #5
0
        public static async Task <List <Appointment> > GetReccurantAppointments(Appointment currentAppointment,
                                                                                string localId)
        {
            var appointmentStore =
                await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            var resultList = new List <Appointment>();

            if (currentAppointment.Recurrence != null)
            {
                var calendar =
                    await appointmentStore.GetAppointmentCalendarAsync(currentAppointment.CalendarId);


                var appointmentInstances = await
                                           calendar.FindAllInstancesAsync(
                    localId,
                    DateTime.Today,
                    TimeSpan.FromDays(App.ViewModel.Days.Count),
                    CalendarAPI.GetFindOptions());

                resultList.AddRange(appointmentInstances);
            }
            else
            {
                resultList.Add(currentAppointment);
            }
            return(resultList);
        }
Example #6
0
        private async void AddToCal_Click(object sender, RoutedEventArgs e)
        {
            DateTime myDateTime       = ReturnDateTime(Date);
            var      duration         = new DateTimeOffset(myDateTime.AddDays(1)) - new DateTimeOffset(myDateTime);
            var      appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            var daysAppointments = await appointmentStore.FindAppointmentsAsync(myDateTime, duration);

            var daysAppointmentsSubjects = daysAppointments.Select(n => n.Subject);

            if (!daysAppointmentsSubjects.Contains("Премьера фильма \"" + CinemaTitle + "\""))
            {
                Appointment Premiere = new Appointment();
                Premiere.Subject   = "Премьера фильма \"" + CinemaTitle + "\"";
                Premiere.StartTime = myDateTime;
                Premiere.AllDay    = true;
                Premiere.Location  = "Park Cinema";

                await appointmentStore.ShowAddAppointmentAsync(Premiere, new Rect());
            }
            else
            {
                await new MessageDialog("Напоминание ранее было добавлено в календарь").ShowAsync();
            }
        }
Example #7
0
        public void ReturnCorrectLastHourOfDay()
        {
            var actual        = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var lastTimeOfDay = actual.Last().TimeOfDay;

            lastTimeOfDay.Should().Be(new TimeSpan(0, 15, 45, 0));
        }
Example #8
0
        public void InsertTest()
        {
            var      task1    = CustomerManager.Load();
            Customer customer = task1.Result.FirstOrDefault();

            task1.Wait();

            var      task2    = EmployeeManager.Load();
            Employee employee = task2.Result.FirstOrDefault();

            task2.Wait();

            var         task3       = ServiceTypeManager.Load();
            ServiceType serviceType = task3.Result.FirstOrDefault();

            task3.Wait();

            Appointment appointment = new Appointment
            {
                CustomerId    = customer.Id,
                EmployeeId    = employee.Id,
                StartDateTime = DateTime.Now,
                EndDateTime   = DateTime.Now.AddHours(2),
                ServiceId     = serviceType.Id,
                Status        = AppointmentStatus.Scheduled.ToString()
            };

            var  task4  = AppointmentManager.Insert(appointment, true);
            bool result = task4.Result;

            task4.Wait();

            Assert.IsTrue(result == true);
        }
Example #9
0
        public void TestAppointmentRemove()
        {
            // arrange
            int result = 0;
            AppointmentLocationVM appointment = new AppointmentLocationVM()
            {
                AppointmentID         = 1,
                AdoptionApplicationID = 1,
                AppointmentTypeID     = "InHomeInspection",
                DateTime         = new DateTime(2020, 5, 1, 12, 30, 00),
                Notes            = "",
                Decicion         = "Undecided",
                LocationID       = 1,
                LocationName     = "Home",
                LocationAddress1 = "123 Real Ave",
                LocationCity     = "Marion",
                LocationState    = "IA",
                LocationZip      = "52402"
            };
            IAppointmentManager appointmentManager = new AppointmentManager(_appointmentAccessor);

            // act
            result = appointmentManager.RemoveAppointment(appointment);

            // assert
            Assert.AreEqual(1, result);
        }
Example #10
0
        private void FillInitialData()
        {
            AppointmentManager appointmentManager = new AppointmentManager(_appointmentContext);
            var list = appointmentManager.GetAllItemsAsync().Result;

            if (list.Count < 3)
            {
                var x = appointmentManager.CreateAsync(new Appointment()
                {
                    PatientId           = "19860813-1111",
                    DoctorId            = "201012-1425",
                    AppointmentDate     = DateTime.UtcNow.AddDays(1).Date,
                    AppointmentTimeSlot = 1
                }).Result;

                x = appointmentManager.CreateAsync(new Appointment()
                {
                    PatientId           = "19750612-2222",
                    DoctorId            = "201012-1425",
                    AppointmentDate     = DateTime.UtcNow.AddDays(1).Date,
                    AppointmentTimeSlot = 3
                }).Result;

                x = appointmentManager.CreateAsync(new Appointment()
                {
                    PatientId           = "19860813-1111",
                    DoctorId            = "201012-1425",
                    AppointmentDate     = DateTime.UtcNow.AddDays(1).Date,
                    AppointmentTimeSlot = 1
                }).Result;
            }
        }
Example #11
0
        private async void BtnAppnt_ClickAsync(object sender, RoutedEventArgs e)
        {
            var rect = GetElementRect(sender as FrameworkElement);

            // Store contents of the file into an enumerable List.
            IList <string> lines = await FileIO.ReadLinesAsync(file);

            char chDelimiter;

            // Choose delimited
            if (file.Name.Contains(".csv"))
            {
                chDelimiter = ',';
            }
            else
            {
                chDelimiter = ';';
            }

            foreach (var line in lines)
            {
                // Skip the header or Empty Line
                if (line.Contains("Subject,Date,StartTime,Duration") || line.Equals(String.Empty))
                {
                    continue;
                }

                // Split the contents of the line based on the delimiter
                string[] appointmentDetails = line.Split(chDelimiter);

                // Create a new Appointment object
                Appointment appointment = new Appointment();

                // Expected format of string: Subject,Date,StartTime,Duration
                appointment.Subject = appointmentDetails[0];
                DateTime dateTime = DateTime.ParseExact(String.Format("{0} {1}", appointmentDetails[1], appointmentDetails[2]),
                                                        "dd-MM-yyyy HH:mm",
                                                        System.Globalization.CultureInfo.InvariantCulture);
                DateTimeOffset startTime = new DateTimeOffset(dateTime);
                appointment.StartTime = startTime;
                appointment.Duration  = TimeSpan.FromHours(float.Parse(appointmentDetails[3]));
                appointment.Reminder  = TimeSpan.FromHours(1);

                String appointmentId = await AppointmentManager.ShowAddAppointmentAsync(appointment, rect);

                // Check if appointment was added successfully
                if (appointmentId != String.Empty)
                {
                    if (appointmentId.Length > 10)
                    {
                        appointmentId = appointmentId.Substring(0, 10);
                    }
                    txtStatus.Text = "Appointment Id: " + appointmentId;
                }
                else
                {
                    txtStatus.Text = "Appointment Not added";
                }
            }
        }
        public async Task <bool> AddAppointment(DataAgendaTelefoon agendaAfspraak)
        {
            var appointmentRcd = new Windows.ApplicationModel.Appointments.Appointment();
            var date           = agendaAfspraak.AgendaDatum;
            var time           = agendaAfspraak.AgendaTijd;
            var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
            var startTime      = new DateTimeOffset(date.Year, date.Month, date.Day, time.Hours, time.Minutes, 0, timeZoneOffset);

            appointmentRcd.StartTime = startTime;

            // Subject
            appointmentRcd.Subject = agendaAfspraak.Titel;
            // Location
            appointmentRcd.Location = agendaAfspraak.WaarEnWanneer;
            // Details
            appointmentRcd.Details = agendaAfspraak.Beschrijving;
            // Duration
            appointmentRcd.Duration = TimeSpan.FromHours(1);
            // All Day
            appointmentRcd.AllDay = false;
            //Busy Status
            appointmentRcd.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Busy;
            // Sensitivity
            appointmentRcd.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Public;
            Rect   rect   = new Rect(new Windows.Foundation.Point(10, 10), new Windows.Foundation.Size(100, 200));
            string retVal = await AppointmentManager.ShowAddAppointmentAsync(appointmentRcd, rect, Windows.UI.Popups.Placement.Default);

            return(!string.IsNullOrEmpty(retVal));
        }
Example #13
0
        public async Task <IActionResult> CreateVisitStep3(CreateVisitStep2ViewModel model)
        {
            var correctTime = AppointmentManager.GetAvailableTimes(model.StartDateTime);
            var ccc         = correctTime.Any(d => d.Date.ToString("d") == model.TimeOfDay.ToString("d"));

            if (!ccc)
            {
                ModelState.AddModelError("doctorError", "Niestety, wybrany lekarz jest w tym dniu niedostępny");
            }

            if (!ModelState.IsValid)
            {
            }

            var doctor = await _doctorsRepository.GetDoctorByName(model.DoctorName);

            var createVisitStep3ViewModel = new CreateVisitStep3ViewModel
            {
                StartDateTime = new DateTime(model.StartDateTime.Year, model.StartDateTime.Month,
                                             model.StartDateTime.Day, model.TimeOfDay.Hour, model.TimeOfDay.Minute, 0),
                Doctor      = doctor,
                DoctorName  = model.DoctorName,
                Description = model.Description,
                TimeOfDay   = model.TimeOfDay
            };

            return(View(createVisitStep3ViewModel));
        }
        public async void ExportToCalendar(object item)
        {
            var       animeItemViewModel = item as AnimeItemViewModel;
            DayOfWeek day  = Utilities.StringToDay(animeItemViewModel.TopLeftInfoBind);
            var       date = GetNextWeekday(DateTime.Today, day);

            var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
            var startTime      = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, timeZoneOffset);

            var appointment = new Appointment();

            appointment.StartTime = startTime;
            appointment.Subject   = "Anime - " + animeItemViewModel.Title;
            appointment.AllDay    = true;

            var recurrence = new AppointmentRecurrence();

            recurrence.Unit       = AppointmentRecurrenceUnit.Weekly;
            recurrence.Interval   = 1;
            recurrence.DaysOfWeek = UWPUtilities.DayToAppointementDay(day);
            if (animeItemViewModel.EndDate != AnimeItemViewModel.InvalidStartEndDate)
            {
                var endDate = DateTime.Parse(animeItemViewModel.EndDate);
                recurrence.Until = endDate;
            }
            else if (animeItemViewModel.StartDate != AnimeItemViewModel.InvalidStartEndDate &&
                     animeItemViewModel.AllEpisodes != 0)
            {
                var weeksPassed = (DateTime.Today - DateTime.Parse(animeItemViewModel.StartDate)).Days / 7;
                if (weeksPassed < 0)
                {
                    return;
                }
                var weeks = (uint)(animeItemViewModel.AllEpisodes - weeksPassed);
                recurrence.Until = DateTime.Today.Add(TimeSpan.FromDays(weeks * 7));
            }
            else if (animeItemViewModel.AllEpisodes != 0)
            {
                var epsLeft = animeItemViewModel.AllEpisodes - animeItemViewModel.MyEpisodes;
                recurrence.Until = DateTime.Today.Add(TimeSpan.FromDays(epsLeft * 7));
            }
            else
            {
                var msg = new MessageDialog("Not enough data to create event.");
                await msg.ShowAsync();

                return;
            }
            appointment.Recurrence = recurrence;
            var rect = new Rect(new Point(Window.Current.Bounds.Width / 2, Window.Current.Bounds.Height / 2), new Size());

            try
            {
                await AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Placement.Default);
            }
            catch (Exception)
            {
                //appointpent is already being created
            }
        }
        public static async Task <bool> DeleteCalendar(string calendarID)
        {
            var appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadWrite);

            var xml = new XElement("Calendars");

            try
            {
                var calendars = await appointmentStore.FindAppointmentCalendarsAsync();

                foreach (var calendar in calendars)
                {
                    xml.Add(SerializeCalendar(calendar));

                    if (calendar.DisplayName == calendarID)
                    {
                        await calendar.DeleteAsync();

                        return(true);
                    }
                }

                xml.Save(@"C:\Users\ramsi\Documents\files.xml");
                return(false);
            }
            catch (Exception exc)
            {
                xml.Save(@"C:\Users\ramsi\Documents\files.xml");
                return(false);
            }
        }
Example #16
0
        public void TestAppointmentRetrieveById()
        {
            // arrange
            AppointmentLocationVM appointment;
            IAppointmentManager   appointmentManager  = new AppointmentManager(_appointmentAccessor);
            AppointmentLocationVM selectedAppointment = new AppointmentLocationVM()
            {
                AppointmentID         = 1,
                AdoptionApplicationID = 1,
                AppointmentTypeID     = "InHomeInspection",
                DateTime         = new DateTime(2020, 5, 1, 12, 30, 00),
                Notes            = "",
                Decicion         = "Undecided",
                LocationID       = 1,
                Active           = true,
                LocationName     = "Home",
                LocationAddress1 = "123 Real Ave",
                LocationCity     = "Marion",
                LocationState    = "IA",
                LocationZip      = "52402"
            };

            // act
            appointment = appointmentManager.RetrieveAppointmentByID(selectedAppointment.AppointmentID);

            // assert
            // Assert.AreEqual(selectedAppointment, appointment);
            Assert.AreEqual(selectedAppointment.AppointmentID, appointment.AppointmentID);
        }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HomeController"/> class.
 /// </summary>
 public HomeController()
 {
     this.msgCenterHelper        = new MessageCenterHelper();
     this.dashBoardManager       = new DashBoardManager();
     this.appointmentManager     = new AppointmentManager();
     this.logiIntegrationManager = new LogiIntegrationManager();
 }
Example #18
0
        private void FillList(string strAppointmentNo, string strName)
        {
            AppointmentList objList = new AppointmentList();

            if (strAppointmentNo == "All")
            {
                strAppointmentNo = "";
            }
            if (strName == "All")
            {
                strName = "";
            }
            objList = AppointmentManager.GetList(Condition, strAppointmentNo, strName, chkClosed.Checked);

            lvwAppoints.Items.Clear();

            if (objList != null)
            {
                foreach (Appointment objAppoint in objList)
                {
                    ListViewItem objLvwItem = new ListViewItem();
                    objLvwItem.Name = Convert.ToString(objAppoint.DBID);
                    objLvwItem.Text = Convert.ToString(objAppoint.EntryNo);
                    objLvwItem.SubItems.Add(objAppoint.EntryDate.ToShortDateString());
                    objLvwItem.SubItems.Add(Convert.ToString(objAppoint.AppointmentNo));
                    objLvwItem.SubItems.Add(objAppoint.Name);
                    objLvwItem.SubItems.Add(objAppoint.AppointmentDate.ToShortDateString());
                    objLvwItem.SubItems.Add(objAppoint.ScheduleTime.ToShortTimeString());

                    lvwAppoints.Items.Add(objLvwItem);
                }
            }
        }
Example #19
0
 private static async Task EnsureAvailabilityAsync()
 {
     if (_store == null)
     {
         _store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
     }
 }
Example #20
0
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvwAppoints.SelectedItems != null && lvwAppoints.SelectedItems.Count != 0)
                {
                    if (IsList)
                    {
                        btnOk_Click(sender, e);
                    }
                    else
                    {
                        if (objUIRights.ModifyRight)
                        {
                            Appointment        objAppoint;
                            frmAppointmentProp objFrmProp;

                            objAppoint                    = AppointmentManager.GetItem(Convert.ToInt32(lvwAppoints.SelectedItems[0].Name));
                            objFrmProp                    = new frmAppointmentProp(objAppoint, objCurUser);
                            objFrmProp.MdiParent          = this.MdiParent;
                            objFrmProp.Entry_DataChanged += new frmAppointmentProp.AppointUpdateHandler(Entry_DataChanged);
                            objFrmProp.Show();
                        }
                        else
                        {
                            throw new Exception("Not Authorised.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #21
0
        public void ReturnTimesEveryFifteenMinutes()
        {
            var actual           = AppointmentManager.GetAvailableTimes(DateTime.Today.AddDays(1));
            var diffBetweenTimes = actual[1] - actual[0];

            diffBetweenTimes.Should().Be(new TimeSpan(0, 0, 15, 0));
        }
Example #22
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvwAppoints.SelectedItems != null && lvwAppoints.SelectedItems.Count != 0)
                {
                    if (!IsList)
                    {
                        if (objUIRights.DeleteRight)
                        {
                            DialogResult dr = new DialogResult();
                            dr = MessageBox.Show("Do You Really Want to Delete Record ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                            if (dr == DialogResult.Yes)
                            {
                                Appointment objAppoint = new Appointment();
                                objAppoint = AppointmentManager.GetItem(Convert.ToInt32(lvwAppoints.SelectedItems[0].Name));
                                AppointmentManager.Delete(objAppoint);
                                lvwAppoints.Items.Remove(lvwAppoints.SelectedItems[0]);
                            }
                        }
                        else
                        {
                            throw new Exception("Not Authorised.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #23
0
        public static async Task CreateAppointment(ITask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            if (task.Due.HasValue)
            {
                var appointment = new Appointment
                {
                    AllDay  = true,
                    Subject = task.Title,
                    Details = task.Note
                };

                DateTime       date           = task.Due.Value;
                TimeSpan       timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
                DateTimeOffset startTime      = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, timeZoneOffset);

                appointment.StartTime = startTime;

                string appointmentId = await AppointmentManager.ShowAddAppointmentAsync(
                    appointment,
                    new Rect(20, 20, 100, 100),
                    Placement.Default);
            }
        }
Example #24
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);
            try
            {
                appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                if (appointmentStore != null)
                {
                    status.Log(LocalizableStrings.CALENDAR_APPOINTMENTSTORE_FIND_SUCCESS);
                    ShowAllCalendars();
                    ShowAllAppointments();
                    Add.IsEnabled     = true;
                    Refresh.IsEnabled = true;
                }
                else
                {
                    status.Log(LocalizableStrings.CALENDAR_APPOINTMENTSTORE_FIND_FAIL);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("CalendarPage.OnNavigatedTo: " + ex.ToString());
                status.Log(ex.GetType().ToString());
            }
        }
Example #25
0
 public AppointmentsController(EMSContext context)
 {
     _context         = context;
     manager          = new AppointmentManager(context);
     validator        = new AppointmentValidation(context.Appointments);
     patientValidator = new PatientValidation(context.Patients);
 }
Example #26
0
        protected void ButtonAddAppointment_Click(object sender, EventArgs e)
        {
            List <Doctor> doctors = getDoctors();

            Doctor doctor = doctors[DropDownListPatients.SelectedIndex];

            DateTime date = getRequestedAppointmentTime();

            AppointmentInfo appointment = new AppointmentInfo(
                TextBoxDepartment.Text,
                getPatientID(),
                doctor.DoctorID,
                date,
                TextBoxPurpose.Text
                );

            if (!AppointmentManager.IsAppointmentAvailable(appointment))
            {
                LabelAddStatus.Text = "That appointment slot is not available, please select a different time/date.";
                return;
            }

            bool scheduleSuccess = AppointmentManager.CreateAppointment(appointment);

            if (scheduleSuccess)
            {
                LabelAddStatus.Text = "Your appointment has been created.";
            }
            else
            {
                LabelAddStatus.Text = "There was an error while scheduling your appointment, please try again later.";
            }
        }
Example #27
0
        public async void Add(object sender, DatePicker startDate, TimePicker startTime,
                              TextBox subject, TextBox location, TextBox details, ComboBox duration, CheckBox allDay)
        {
            FrameworkElement element   = (FrameworkElement)sender;
            GeneralTransform transform = element.TransformToVisual(null);
            Point            point     = transform.TransformPoint(new Point());
            Rect             rect      = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
            DateTimeOffset   date      = startDate.Date;
            TimeSpan         time      = startTime.Time;
            int minutes = int.Parse((string)((ComboBoxItem)duration.SelectedItem).Tag);

            Appointment appointment = new Appointment()
            {
                StartTime = new DateTimeOffset(date.Year, date.Month, date.Day,
                                               time.Hours, time.Minutes, 0, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now)),
                Subject  = subject.Text,
                Location = location.Text,
                Details  = details.Text,
                Duration = TimeSpan.FromMinutes(minutes),
                AllDay   = (bool)allDay.IsChecked
            };
            string id = await AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Placement.Default);

            if (string.IsNullOrEmpty(id))
            {
                Show("Appontment not added", "Appointment App");
            }
            else
            {
                Show(string.Format("Appointment {0} added", id), "Appoitment App");
            }
        }
        private async Task GetBoldedDates(DateTime start, DateTime end)
        {
            DateList boldedDates = calendar.BoldedDates;

            if (!UseAppointmentManager)
            {
                // generate test appointment
                List <object> list = new List <object>();
                Appointment   app  = new Appointment();
                app.Start   = start.AddDays(12);
                app.End     = app.Start.AddHours(1);
                app.Subject = Strings.EmulatorAppointmentSubject;
                list.Add(app);
                // bind calendar to data
                calendar.DataSource = list;
                // don't set StartTimePath and EndTimePath as they are the same as default values
            }
            else
            {
                // get appointments from the device calendar
                var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                var appointments = await store.FindAppointmentsAsync(new DateTimeOffset(start), end - start);

                // bind calendar to the search results
                calendar.DataSource = appointments;
                // don't set StartTimePath and EndTimePath as they are the same as default values
            }
        }
 //Submit button onClock event
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         Appointment app = new Appointment();
         app.firstName    = this.textBoxFirstName.Text;
         app.lastName     = this.textBoxLastName.Text;
         app.departmentId = Int32.Parse(this.comboBoxDepartment.SelectedValue.ToString());
         app.age          = Convert.ToInt32(this.textBoxAge.Text);
         app.doctorId     = docId;
         app.sex          = this.comboBoxSex.Text;
         app.phone        = Convert.ToInt64(this.textBoxPhone.Text);
         app.appTime      = DateTime.Parse(this.dateTimePickerAppointmentTime.Value.ToString());
         app.patientId    = patId;
         AppointmentManager.appointmentSave(app);
         MessageBox.Show("Success");
         displayPatient();
         clearSearchBoxes();
         clearData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #30
0
        private async void RemindMe_Click(object sender, RoutedEventArgs e)
        {
            DateTime myDateTime       = new DateTime(DateTime.Now.Date.Year, DateTime.Now.Date.Month, DateTime.Now.Date.Day, 19, 0, 0);
            var      duration         = new DateTimeOffset(myDateTime.AddDays(1)) - new DateTimeOffset(myDateTime);
            var      appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            var daysAppointments = await appointmentStore.FindAppointmentsAsync(myDateTime, duration);

            var daysAppointmentsSubjects = daysAppointments.Select(n => n.Subject);

            string Subject = App.resourceLoader.GetString("BuyProducts") + " \"" + this.GroupTitle.Text + "\"";

            if (!daysAppointmentsSubjects.Contains(Subject))
            {
                Appointment Premiere = new Appointment();
                Premiere.Subject   = Subject;
                Premiere.StartTime = myDateTime;
                Premiere.AllDay    = false;
                Premiere.Reminder  = new TimeSpan();

                await appointmentStore.ShowAddAppointmentAsync(Premiere, new Rect());
            }
            else
            {
                MessageDialog mg = new MessageDialog(App.resourceLoader.GetString("AddedReminder"));
                mg.Title = App.resourceLoader.GetString("Attention");

                await mg.ShowAsync();
            }
        }