private async void CancelAppointment_Clicked(object sender, EventArgs e) { var username = Application.Current.Properties["USER_NAME"] as string; if (username != null & username != "") { AppointmentJson json = new AppointmentJson(); json.UserName = username; json.AppointmentDate = AppointmentDateFrom.Date.ToString("dd/MM/yyyy"); json.AppointmentTime = AppointmentTimeFrom.Time.ToString(@"hh\:mm"); Device.BeginInvokeOnMainThread(async() => { string result = await apiRequestHelper.RequestCheckExistAppointmentAsync(json); if (result == "true") { json.IsApprove = ""; json.IsCancel = "Y"; json.CancelReason = Subject.Text.Trim(); json.Status = "รอการยืนยัน"; await apiRequestHelper.RequestUpdateAppointmentAsync(json); Toast.MakeText(context, "บันทึกข้อมูลสำเร็จ", ToastLength.Short).Show(); List <Page> li = Navigation.NavigationStack.ToList(); Page last = li.ElementAt(li.Count - 1); Navigation.RemovePage(last); } else { Toast.MakeText(context, "ไม่พบข้อมูลนัดหมาย วัน" + json.AppointmentDate + " เวลา: " + json.AppointmentTime + " !", ToastLength.Short).Show(); } }); } }
public List <AppointmentJson> appointmentsByDate(int month, int day) { List <AppointmentJson> appsJson = new List <AppointmentJson>(); AppointmentJson json; var appos = _context.Appointments.Where(r => r.Date.Month == month && r.Date.Day == day).Include(a => a.Patient).ToList(); foreach (var item in appos) { json = new AppointmentJson { Date = item.Date, Day = item.Date.Day, Month = item.Date.Month, Year = item.Date.Year, PatientID = item.PatientID, ID = item.ID, Prescription = item.Prescription, Status = item.Status, Name = item.Patient.Name }; appsJson.Add(json); } return(appsJson); }