コード例 #1
0
        public async Task <ActionResult> Patients(int?id, CancellationToken ct)
        {
            _credentials.OnBehalfOf = User.Identity.GetUserId();
            if (id == null)
            {
                return(await ViewPatients(ct));
            }
            var cache = new ResponseCache <PatientViewModel>(false, DefaultCacheTime.Long, _settings.ResponseCacheEnabled,
                                                             _settings.ResponseCacheDefaultShortTimeInMinutes, _settings.ResponseCacheDefaultLongTimeInMinutes);
            var patientModel = cache.GetValue(Request);

            if (patientModel == null)
            {
                var muscles = await _glanceDa.GetMusclesAsync(_credentials, ct);

                var yearBounds = await _glanceDa.GetYearBoundsAsync(_credentials, id.Value, ct);

                var patient = await _glanceDa.GetPatientAsync(_credentials, id.Value, ct);

                patientModel = new PatientViewModel
                {
                    Name    = patient.Name,
                    Keycol  = id.Value,
                    YearMax = yearBounds.Max,
                    YearMin = yearBounds.Min,
                    Muscles = muscles.ToArray(),
                };
                cache.SetValue(Request, patientModel);
            }
            patientModel.VersionedSettings = new Tuple <string, string>(string.Empty, "{}");
            return(View("Patient", patientModel));
        }
コード例 #2
0
        public async Task <ActionResult> Patients(int?id, CancellationToken ct)
        {
            _credentials.OnBehalfOf = User.Identity.GetUserId();
            if (id == null)
            {
                return(await ViewPatients(ct));
            }
            var cache = new ResponseCache <PatientViewModel>(false, DefaultCacheTime.Long, _settings.ResponseCacheEnabled,
                                                             _settings.ResponseCacheDefaultShortTimeInMinutes, _settings.ResponseCacheDefaultLongTimeInMinutes);
            var patientModel = cache.GetValue(Request);

            if (patientModel == null)
            {
                var muscles = await _glanceDa.GetMusclesAsync(_credentials, ct);

                var yearBounds = await _glanceDa.GetYearBoundsAsync(_credentials, id.Value, ct);

                var patient = await _glanceDa.GetPatientAsync(_credentials, id.Value, ct);

                patientModel = new PatientViewModel
                {
                    Name    = patient.Name,
                    Id      = id.Value,
                    YearMax = yearBounds.Max,
                    YearMin = yearBounds.Min,
                    Muscles = muscles.ToArray(),
                };
                cache.SetValue(Request, patientModel);
            }
            var settings = await _glanceDa.GetSettingsAsync(_credentials, User.Identity.GetUserId(), ct);

            if (settings != null)
            {
                var etag = "W/\"" + EncodeInBase64(string.Format("binary'{0}'",
                                                                 Convert.ToBase64String(settings.Version, 0, settings.Version.Length))) + "\"";
                patientModel.VersionedSettings = new Tuple <string, string>(etag, settings.Value);
            }
            else
            {
                patientModel.VersionedSettings = new Tuple <string, string>(string.Empty, "{}");
            }
            return(View("Patient", patientModel));
        }