// GET: PcoLicencesDetails/Create public async Task <ActionResult> Create(string id) { var decodedId = GuidEncoder.Decode(id).ToString(); var path = string.Format("{0}/{1}", Pdl_ByAppUserId, decodedId); var pld = _mapper.Map <PcoLicenceDetailViewModel>(await _apiClient.GetAsync <PcoLicenceDetailDto>(path)); if (pld == null) { var newPdl = new PcoLicenceDetailViewModel() { AppUserUriKey = id }; return(View(newPdl)); } else { return(View()); } }
public async Task <ActionResult> Edit(PcoLicenceDetailViewModel model) { var path = string.Format("{0}/{1}", BaseUri, model.UriKey); try { // TODO: Add update logic here if (ModelState.IsValid) { await _apiClient.PutAsync <PcoLicenceDetailDto>(_mapper.Map <PcoLicenceDetailDto>(model)); return(RedirectToAction(nameof(Index))); } return(View()); } catch (Exception ex) { var errMsg = ex.Message; return(View()); } }
public async Task <ActionResult> Create(PcoLicenceDetailViewModel model) { try { if (ModelState.IsValid) { var decodedId = GuidEncoder.Decode(model.AppUserUriKey).ToString(); var path = string.Format("{0}/{1}", BaseUri_AppUserById, decodedId); var appUser = _mapper.Map <AppUserViewModel>(await _apiClient.GetAsync <AppUserDto>(path)); //var updateAppUserPath = string.Format("{0}", BaseUri_AppUser); //model.AppUserId = string.Empty; //model.AppUserId = appUser.AppUserId; //appUser.PcoLicenceDetail = model; //await _apiClient.PutAsync<AppUserDto>(updateAppUserPath, _mapper.Map<AppUserDto>(appUser)); //var createPath = string.Format("{0}",Pdl_PostPdl); //model.AppUserId = appUser.AppUserId; //await _apiClient.PostAsync<PcoLicenceDetailDto>(createPath, _mapper.Map<PcoLicenceDetailDto>(model)); var createPath = string.Format("{0}{1}", HttpClientProvider.HttpClient.BaseAddress, Pdl_PostPdl); //model.AppUser = appUser; model.AppUserId = appUser.AppUserId; await _apiClient.PostAsync <PcoLicenceDetailDto>(createPath, _mapper.Map <PcoLicenceDetailDto>(model)); return(RedirectToAction(nameof(Index))); } // TODO: Add insert logic here return(View()); } catch (Exception ex) { var errMsg = ex.Message; return(View()); } }