public async Task <IActionResult> ReceptionistAccount() { _logger.Log(LogLevel.Debug, "AccountController::ReceptionistAccount()"); if (TempData["message"] != null) { ModelState.AddModelError("CredentialChanged", _localizer[TempData["message"].ToString()]); } try { var id = _contextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; var receptionist = await _client.SendRequestAsync <Receptionist>(HttpMethod.Get, $"Account/{id}"); var model = new ReceptionistAccountViewModel(); model.Email = receptionist.Email; model.FirstName = receptionist.FirstName; model.LastName = receptionist.LastName; model.DateOfBirth = receptionist.DateOfBirth; model.Sex = receptionist.Sex; return(View(model)); } catch (HttpRequestException) { //show error return(View()); } }
public async Task <IActionResult> Index(PhysicianSpecialization specialization, DateTime startDate, AppointmentType appointmentType) { var model = new AddAppointmentViewModel { FreeTerms = new List <Appointment>() }; if (startDate < DateTime.Now) { return(View(model)); } try { var builder = new StringBuilder("Appointments/free/?"); var query = HttpUtility.ParseQueryString(string.Empty); query["specialization"] = specialization.ToString(); query["startDate"] = startDate.ToString("MM.dd.yyyy"); // little hack query["type"] = appointmentType.ToString(); builder.Append(query.ToString()); model.FreeTerms = await _client.SendRequestAsync <List <Appointment> >(HttpMethod.Get, builder.ToString()); return(View(model)); } catch (HttpRequestException) { ModelState.AddModelError("TryAgain", _localizer["TryAgain"]); return(View(model)); } }
private async Task <List <Patient> > GetAllPatientsAsync() { List <Patient> patients; try { patients = await _cacheService.GetPatientsAsync(); if (patients == null) { patients = await _client.SendRequestAsync <List <Patient> >(HttpMethod.Get, "Patients"); _cacheService.SetPatientsAsync(patients); } } catch (HttpRequestException) { throw new ServerConnectionException(); } return(patients); }
public async Task <IActionResult> AllPatients() { if (TempData["message"] != null) { ModelState.AddModelError("info", _localizer[TempData["message"].ToString()]); } try { var model = new PatientsViewModel(); model.Patients = await _cacheService.GetPatientsAsync(); if (model.Patients == null) { model.Patients = await _client.SendRequestAsync <List <Patient> >(HttpMethod.Get, "Patients"); _cacheService.SetPatientsAsync(model.Patients); } return(View(model)); } catch (HttpRequestException) { throw new ServerConnectionException(); } }
public async Task <IActionResult> Cancel(int id) { try { var appointment = await _client.SendRequestAsync <Appointment>(HttpMethod.Delete, $"Appointments/{id}"); TempData["Message"] = "AppointmentCanceled"; return(RedirectToAction(nameof(CalendarController.Receptionist), "Calendar")); } catch (HttpRequestException) { throw new ServerConnectionException(); } }