Example #1
0
        public AppointmentMessage GetById(Guid id)
        {
            AppointmentMessage appointmentMessage = new AppointmentMessage();

            try
            {
                if (id != Guid.Empty)
                {
                    var appointmentEntity = _db.Appointment.Find(id);

                    if (appointmentEntity != null)
                    {
                        appointmentMessage = new AppointmentMessage
                        {
                            Id                  = appointmentEntity.Id,
                            Date                = appointmentEntity.Date,
                            State               = appointmentEntity.State,
                            IdAppointmentType   = appointmentEntity.IdAppointmentType,
                            IdPatient           = appointmentEntity.IdPatient,
                            NameAppointmentType = AppointmentTypeService.GetNameById(appointmentEntity.IdAppointmentType),
                            NameState           = AppointmentStateService.GetNameById(appointmentEntity.State),
                            FullNamePatient     = appointmentEntity.Patient.FirstName + " " + appointmentEntity.Patient.LastName
                        };
                    }
                }

                return(appointmentMessage);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        public List <AppointmentMessage> GetList()
        {
            List <AppointmentMessage> listAppointmentMessage = new List <AppointmentMessage>();

            try
            {
                var appointmentEntity = _db.Appointment.ToList();

                if (appointmentEntity?.Count > 0)
                {
                    foreach (var item in appointmentEntity)
                    {
                        listAppointmentMessage.Add(new AppointmentMessage
                        {
                            Id                  = item.Id,
                            State               = item.State,
                            Date                = item.Date,
                            IdAppointmentType   = item.IdAppointmentType,
                            IdPatient           = item.IdPatient,
                            NameAppointmentType = AppointmentTypeService.GetNameById(item.IdAppointmentType),
                            NameState           = AppointmentStateService.GetNameById(item.State),
                            FullNamePatient     = item.Patient.FirstName + " " + item.Patient.LastName
                        });
                    }
                }

                return(listAppointmentMessage);
            }
            catch (Exception e)
            {
                throw e;
            }
        }