public async Task <IActionResult> EditExperienceAsync(Guid id) { EditExperienceViewModel viewModel = new EditExperienceViewModel(); using (HttpClient client = new HttpClient()) { HttpResponseMessage experienceResponse = await _oplevOgDelService.Client.GetAsync(_apiUrls.Experiences + $"/{id}"); if (experienceResponse.IsSuccessStatusCode) { viewModel.Experience = await experienceResponse.Content.ReadAsAsync <ExperienceDto>(); } HttpResponseMessage categoriesResponse = await _oplevOgDelService.Client.GetAsync(_apiUrls.Categories); if (categoriesResponse.IsSuccessStatusCode) { var categories = await categoriesResponse.Content.ReadAsAsync <List <CategoryDto> >(); viewModel.Categories = categories.Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }); } } return(View(viewModel)); }
public async Task <IActionResult> UpdateExperience([FromBody] EditExperienceViewModel experience) { try { if (ModelState.IsValid) { String id = " "; String talentId = String.IsNullOrWhiteSpace(id) ? _userAppContext.CurrentUserId : id; var user = _userRepository.GetByIdAsync(talentId).Result; var updateExp = user.Experience.SingleOrDefault(x => x.Id == experience.Id); { updateExp.Company = experience.Company; updateExp.Position = experience.Position; updateExp.Responsibilities = experience.Responsibilities; updateExp.Start = experience.Start; updateExp.End = experience.End; } await _userRepository.Update(user); } return(Json(new { Success = true })); } catch (Exception e) { return(Json(new { Success = false, message = e })); } }
public EditExperiencePage(Experience experience) { var EditViewModel = new EditExperienceViewModel(); EditViewModel.TheSelectedxperience = experience; BindingContext = EditViewModel; InitializeComponent(); }