public IList <OrganStateSnapshotViewModel> GetByPatientRequestId(int patientRequestId)
        {
            var patRequest        = _patientRequestsService.GetDetailedById(patientRequestId);
            var donorRequest      = patRequest.RequestsRelation.DonorRequest;
            var transplantOrganId = donorRequest.TransplantOrganId;

            if (!transplantOrganId.HasValue)
            {
                return(Enumerable.Empty <OrganStateSnapshotViewModel>()
                       .ToList());
            }

            var snapshots = _deliverySnapshotsRepository.GetByTransplantOrganId(transplantOrganId.Value)
                            .TakeLast(10);

            return(snapshots.Select(snapshot => new OrganStateSnapshotViewModel()
            {
                PatientRequestId = patientRequestId,
                Temperature = snapshot.Temperature,
                Humidity = snapshot.Humidity,
                Time = snapshot.Time,
                Longitude = snapshot.Longitude,
                Altitude = snapshot.Altitude
            }).ToList());
        }
        public IActionResult GetPatientRequestDetails(int id)
        {
            int  patientRequestId = id;
            bool hasRights        = _userManager.IsUserInMedEmployeeRole(User.Identity.Name);

            if (!hasRights)
            {
                var user = _userManager.FindByNameAsync(User.Identity.Name).Result;
                hasRights = _patientRequestService.HasPatientRequest(user.Id, patientRequestId);
            }
            if (!hasRights)
            {
                return(Unauthorized());
            }

            var response = ContentExecute <PatientRequestDetailsViewModel>(() =>
            {
                var patientRequest = _patientRequestService.GetDetailedById(patientRequestId);
                return(new PatientRequestDetailsViewModel(patientRequest, patientRequest.RequestsRelation?.DonorRequest));
            });

            return(Json(response));
        }