public List <Appointment> GetAvailableAppointment(int idLpu, string idDoc, string idPat, string selectDate) { List <Appointment> appointment = new List <Appointment>(); netricaClient = new HubServiceClient(new HubServiceClient.EndpointConfiguration()); var r = netricaClient.GetAvaibleAppointmentsAsync(idDoc, idLpu, idPat, DateTime.Today, DateTime.Today.AddDays(14), Startup.Configuration["GUID"], null); if (r.Result.ListAppointments != null) { for (int i = 0; i < r.Result.ListAppointments.Count(); i++) { if (r.Result.ListAppointments[i].VisitStart.ToShortDateString() == selectDate) { appointment.Add(new Appointment { Address = r.Result.ListAppointments[i].Address, IdAppointment = r.Result.ListAppointments[i].IdAppointment, Num = r.Result.ListAppointments[i].Num, Room = r.Result.ListAppointments[i].Room, VisitEnd = r.Result.ListAppointments[i].VisitEnd, VisitStart = r.Result.ListAppointments[i].VisitStart }); } } netricaClient.CloseAsync(); } else { appointment = null; } netricaClient.CloseAsync(); return(appointment); }
public List <AvialableDateModel> GetAvailableDates(int idLpu, string idDoc, string idPat, DateTime dayStart, DateTime dayEnd) { List <AvialableDateModel> dates = new List <AvialableDateModel>(); AvialableDateModel avialableDateModel; netricaClient = new HubServiceClient(new HubServiceClient.EndpointConfiguration()); var r = netricaClient.GetAvaibleAppointmentsAsync(idDoc, idLpu, idPat, dayStart, dayEnd, Startup.Configuration["GUID"], null); if (r.Result.ListAppointments != null) { avialableDateModel = new AvialableDateModel(r.Result.ListAppointments[0].VisitStart.Date); foreach (var avialableDateModel_1item in r.Result.ListAppointments) { if (avialableDateModel?.date.ToShortDateString() != avialableDateModel_1item.VisitStart.Date.ToShortDateString()) { avialableDateModel = new AvialableDateModel(avialableDateModel_1item.VisitStart.Date); } if (avialableDateModel.countFreeTicket == 0) { foreach (var avialableDateModel_2item in r.Result.ListAppointments) { if (avialableDateModel_2item.VisitStart.Date == avialableDateModel.date) { avialableDateModel.countFreeTicket++; } else { continue; } } dates.Add(avialableDateModel); } } netricaClient.CloseAsync(); } else { dates = null; } return(dates); }