Example #1
0
        public async Task <IActionResult> UpdateAddress(Guid id, UpdatePatientAddressViewModel patientViewModel)
        {
            if (id != patientViewModel.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(patientViewModel));
            }

            var client   = _clientFactory.CreateClient();
            var response =
                await client.PostAsync(
                    "https://csu-patient.azurewebsites.net/patient-management-update-address",
                    new StringContent(JsonConvert.SerializeObject(patientViewModel), Encoding.UTF8,
                                      "application/json"));

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction(nameof(Index)));
            }

            return(BadRequest());
        }
Example #2
0
        public async Task <IActionResult> UpdatePatientAddress([FromBody] UpdatePatientAddressViewModel patientViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(patientViewModel));
            }

            _patientAppService.UpdateAddress(patientViewModel);

            return(Response(patientViewModel));
        }
Example #3
0
        // GET: Patient/UpdateAddress/5
        public async Task <IActionResult> UpdateAddress(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"https://csu-patient.azurewebsites.net/patient-information/{id}");

            var client = _clientFactory.CreateClient();

            var response = await client.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                return(NotFound());
            }

            var responseStream = await response.Content.ReadAsStringAsync();

            var patientViewModel = JsonConvert.DeserializeObject <PatientViewModel>(responseStream);

            if (patientViewModel == null)
            {
                return(NotFound());
            }

            var addressViewModel = new UpdatePatientAddressViewModel
            {
                Id          = patientViewModel.Id,
                City        = patientViewModel.Address.City,
                District    = patientViewModel.Address.District,
                Number      = patientViewModel.Address.Number,
                Observation = patientViewModel.Address.Observation,
                PostalCode  = patientViewModel.Address.PostalCode,
                State       = patientViewModel.Address.State,
                Street      = patientViewModel.Address.Street
            };

            return(View(addressViewModel));
        }
Example #4
0
        public void UpdateAddress(UpdatePatientAddressViewModel patientAddressViewModel)
        {
            var registerCommand = _mapper.Map <UpdatePatientAddressCommand>(patientAddressViewModel);

            _bus.SendCommand(registerCommand);
        }