Ejemplo n.º 1
0
        private async void SaveConsultation(object consultationObject)
        {
            Consultation consultation = consultationObject as Consultation;

            if (consultation != null)
            {
                IsBusy = true;
                // редактирование
                if (consultation.Id > 0)
                {
                    Consultation updatedConsultation = await consultationsService.Update(consultation);

                    // заменяем объект в списке на новый
                    if (updatedConsultation != null)
                    {
                        int pos = Consultations.IndexOf(updatedConsultation);
                        Consultations.RemoveAt(pos);
                        Consultations.Insert(pos, updatedConsultation);
                    }
                }
                // добавление
                else
                {
                    Consultation addedConsultation = await consultationsService.Add(consultation);

                    if (addedConsultation != null)
                    {
                        Consultations.Add(addedConsultation);
                    }
                }
                IsBusy = false;
            }
            Back();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Register a patient and schedule a consulation
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public static HttpStatusCode RegisterPatient(Patient patient)
        {
            if (Patients == null)
            {
                Patients = new List <Patient>();
            }

            Patients.Add(patient);

            if (Consultations == null)
            {
                Consultations = new List <Consultation>();
            }

            var scheduler    = new ConsultationScheduler();
            var consultation = scheduler.ScheduleConsultation(patient);

            if (consultation == null)
            {
                return(HttpStatusCode.BadRequest);
            }

            Consultations.Add(consultation);

            return(HttpStatusCode.Created);
        }
Ejemplo n.º 3
0
        public async Task GetConsultations()
        {
            if (initialized == true)
            {
                return;
            }
            IsBusy = true;
            IEnumerable <Consultation> consultations = await consultationsService.Get();

            // очищаем список
            //Consultations.Clear();
            while (Consultations.Any())
            {
                Consultations.RemoveAt(Consultations.Count - 1);
            }

            // добавляем загруженные данные
            foreach (Consultation c in consultations)
            {
                Consultations.Add(c);
            }
            IsBusy      = false;
            initialized = true;
        }