public async Task <ActionResult> Details(int id) { appointmentApi = new AppointmentApiClient(); Appointment appointment = await appointmentApi.GetAppointment(id); return(View(appointment)); }
public async Task <ActionResult> Edit(int id) { appointmentApi = new AppointmentApiClient(); hairSalonApi = new HairSalonApiClient(); Appointment appointment = await appointmentApi.GetAppointment(id); HairSalon hairSalon = await hairSalonApi.GetHairSalon(appointment.HairSalonId); List <SelectListItem> workers = new List <SelectListItem>(); List <SelectListItem> services = new List <SelectListItem>(); List <SelectListItem> methodsOfPayment = new List <SelectListItem>(); foreach (var worker in hairSalon.Workers) { workers.Add(new SelectListItem() { Value = worker.Id.ToString(), Text = worker.GetFullName() }); } foreach (var hairSalonService in hairSalon.HairSalonServices) { services.Add(new SelectListItem() { Value = hairSalonService.ServiceId.ToString(), Text = hairSalonService.Service.ToString() }); } foreach (var hairSalonMethodsOfPayment in hairSalon.HairSalonMethodsOfPayment) { methodsOfPayment.Add(new SelectListItem() { Value = hairSalonMethodsOfPayment.MethodOfPaymentId.ToString(), Text = hairSalonMethodsOfPayment.MethodOfPayment.ToString() }); } AppointmentUpdateVM appointmentUpdateVM = new AppointmentUpdateVM() { Date = appointment.Date, Time = appointment.Time, Workers = new SelectList(workers, "Value", "Text"), SelectedWorker = new SelectListItem() { Value = appointment.Worker.Id.ToString(), Text = appointment.Worker.GetFullName() }, AvailableServices = new SelectList(services, "Value", "Text"), MethodsOfPayment = new SelectList(methodsOfPayment, "Value", "Text"), HairSalonId = hairSalon.Id }; return(View(appointmentUpdateVM)); }