private async Task<Surgery> GetSelectedSurgery(DosViewModel model)
 {
     var surgery = new Surgery();
     if (!string.IsNullOrEmpty(model.SelectedSurgery))
         surgery =
             JsonConvert.DeserializeObject<Surgery>(
                 await _restfulHelper.GetAsync(string.Format(_configuration.GPSearchApiUrl, model.SelectedSurgery)));
     else
         surgery.SurgeryId = "UKN";
     return surgery;
 }
 public async Task<ActionResult> FillServiceDetails(DosViewModel model)
 {
     return View("../DOS/Confirmation", await _dosBuilder.FillServiceDetailsBuilder(model));
 }
        public async Task<DosViewModel> FillServiceDetailsBuilder(DosViewModel model)
        {
            var jObj = (JObject)JsonConvert.DeserializeObject(model.CheckCapacitySummaryResultListJson);
            model.CheckCapacitySummaryResultList = jObj["CheckCapacitySummaryResult"].ToObject<CheckCapacitySummaryResult[]>();
            var selectedService = model.CheckCapacitySummaryResultList.FirstOrDefault(x => x.IdField == Convert.ToInt32(model.SelectedService));

            var itkMessage = await _cacheManager.Read(model.UserId.ToString());
            var document = XDocument.Parse(itkMessage);

            var serviceDetials = document.Root.Descendants("ServiceDetails").FirstOrDefault();
            serviceDetials.Element("id").SetValue(selectedService.IdField.ToString());
            serviceDetials.Element("name").SetValue(selectedService.NameField.ToString());
            serviceDetials.Element("odsCode").SetValue(selectedService.OdsCodeField.ToString());
            serviceDetials.Element("contactDetails").SetValue(selectedService.ContactDetailsField ?? "");
            serviceDetials.Element("address").SetValue(selectedService.AddressField.ToString());
            serviceDetials.Element("postcode").SetValue(selectedService.PostcodeField.ToString());

            _cacheManager.Set(model.UserId.ToString(), document.ToString());
            _notifier.Notify(_configuration.IntegrationApiItkDispatcher, model.UserId.ToString());

            model.CheckCapacitySummaryResultList = new CheckCapacitySummaryResult[] { selectedService };
            model.CareAdvices = await _careAdviceBuilder.FillCareAdviceBuilder(Int32.Parse(model.Age), model.Gender, model.CareAdviceMarkers.ToList());

            return model;
        }