/// <summary> /// Get details from doctor /// </summary> /// <param name="id"> id is docterId</param> /// <returns></returns> public IActionResult DoctorDetails(long id) { long userId = GetUserId(); try { UserViewModel viewModel = new UserViewModel(); if (HttpContext.User.IsInRole("doctor")) { if (doctorRepository.CheckDoctorRelationship(userId, id)) { Doctor doctor = doctorRepository.GetById(id); viewModel.Doctor = doctorConverter.ModelToViewModel(doctor); } else { return(RedirectToAction("index", "doctor")); } } else if (HttpContext.User.IsInRole("patient")) { if (treatmentRepository.CheckTreatmentRelationship(id, userId)) { Doctor doctor = doctorRepository.GetById(id); viewModel.Doctor = doctorConverter.ModelToViewModel(doctor); viewModel.Doctor.TreatmentTypes = typeConverter.ModelsToViewModel(treatmentTypeRepository.GetAll()); } else { return(RedirectToAction("index", "treatment")); } } else { return(Unauthorized()); } return(View(viewModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }