public async Task <WatchmanProfile <Guid> > GetWatchmanAsync(Guid id, string token = null)
        {
            var uri = WatchmanUrl + "/get";
            var obj = new { Id = id };

            var response = await _client.SendRequest(HttpMethod.Get, null, obj, uri, token);

            var result = await _client.GetResponseResult(response);

            var dto = !response.IsSuccessStatusCode || String.IsNullOrWhiteSpace(result)
                ? null : JsonConvert.DeserializeObject <WatchmanDto>(result);

            if (dto == null)
            {
                return(null);
            }

            var watchman = new WatchmanInfo {
                Id = dto.Id
            };

            foreach (var pair in dto.WatchmanPatients)
            {
                watchman.WatchmanPatients.Add(new WatchmanPatientImpl()
                {
                    PatientId = pair.PatientId, WatchmanId = pair.WatchmanId
                });
            }

            return(watchman);
        }
예제 #2
0
        public async Task <IActionResult> CreateWatchmanProfile()
        {
            var token = this.GetAccessTokenFromCookies();
            var email = this.GetUserEmailFromHttpContext();

            var          user        = _userManager.FindByEmailAsync(email, token).Result;
            WatchmanInfo newWatchman = new WatchmanInfo()
            {
                Id = Guid.NewGuid()
            };

            await _watchmanPatientService.CreateWatchmanAsync(newWatchman, token);

            await _userHealthService.AddWatchmanToUserAsync(user.Id, newWatchman.Id, token);

            return(RedirectToAction("WatchmanProfile"));
        }