Exemple #1
0
        public async void BuscarSchedulesAsync()
        {
            try
            {
                IsBusy = true;

                Schedules = new ObservableCollection <ScheduleAppointment>();
                Action    = await actionRepository.GetAsync(Action.Id);

                var ex = await scheduleRepository.GetAppointmentsByIdActionAsync(Action.Id);

                for (int i = 0; i < ex.Count(); i++)
                {
                    ScheduleAppointment appointment = new ScheduleAppointment();
                    appointment.Subject   = "Fechado";
                    appointment.Color     = ex.ElementAt(i).Cor;
                    appointment.StartTime = ex.ElementAt(i).StartTime;
                    appointment.EndTime   = ex.ElementAt(i).EndTime;
                    Schedules.Add(appointment);
                }

                IsBusy = false;
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        internal async void LoadAppointment(DateTime date)
        {
            Appointment appointment = null;

            ListEntity dadosPatient = new ListEntity
            {
                Id   = Patient.Id,
                Name = Patient.NameCompleto
            };

            switch (ConsultationType)
            {
            case Appointment._ORIENTACAO:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, false, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;

            case Appointment._GRUPO:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, true, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;

            case Appointment._INDIVIDUAL:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, true, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;
            }

            var appointmentMarcado = (await appointmentRepository.GetAppointmentByEventIdActionIdAsync(appointment.EventId, IdAction, appointment.Patient.Id));

            if (appointmentMarcado == null)
            {
                IEnumerable <ScheduleAction> schedulesIndisponiveis = await scheduleActionRepository.GetAppointmentsByIdActionAsync(IdAction);

                if (schedulesIndisponiveis.FirstOrDefault(x => x.StartTime.DayOfWeek == date.DayOfWeek && x.StartTime.Hour == date.Hour) == null)
                {
                    var action = await dialogService.DisplayActionSheetAsync("Deseja agendar o atendimento?", "Cancelar", "Agendar");

                    switch (action)
                    {
                    case "Cancelar":
                        return;

                    case "Agendar":
                        Create(appointment);
                        break;
                    }
                }
            }
            else
            {
                appointment = appointmentMarcado;
                var action = await dialogService.DisplayActionSheetAsync("Selecione a operação desejada:", "Cancelar", null, "Ver detalhes", "Desmarcar");

                switch (action)
                {
                case "Cancelar":
                    return;

                case "Ver detalhes":
                    OpenAppointment(appointment);
                    break;

                case "Desmarcar":
                    Delete(appointment);
                    break;
                }
            }
        }