/// <summary> /// Detail page for doctor /// </summary> /// <param name="id">Id filter</param> /// <returns></returns> public IActionResult Details(long id) { // Check if id is set if (id < 1) { return(BadRequest("Id cannot be 0")); } // Retrieve doctor Doctor doctor = doctorRepository.GetById(id); if (doctor == null) { return(BadRequest("Department could not be found")); } // Convert to viewmodel and return in view DoctorDetailViewModel vm = converter.ModelToViewModel(doctor); return(View(vm)); }
/// <summary> /// Standard method /// </summary> /// <returns></returns> public IActionResult Index() { try { // Get user id var id = GetUserId(); // Check if it exists if (id < 1) { return(RedirectToAction("index", "home")); } UserViewModel viewModel = new UserViewModel(); // Redirect user based on role if (HttpContext.User.IsInRole("patient")) { Patient patient = patientRepository.GetById(id); viewModel.Patient = patientConverter.ModelToViewModel(patient); } else if (HttpContext.User.IsInRole("doctor")) { Doctor doctor = doctorRepository.GetById(id); viewModel.Doctor = doctorConverter.ModelToViewModel(doctor); //TODO : BY DOCTORID!!!!!! viewModel.Doctor.TreatmentTypes = typeConverter.ModelsToViewModel(treatmentTypeRepository.GetAll()); } return(View(viewModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }