public async Task <IActionResult> Create([Bind("Id,UId,ResumeName, ResumeSlug, UserDisplayName, UserAspiration, Summary,SummaryName,Experience,ExperienceName,Education,EducationName,Skills,SkillsName,Contact,ContactName")] Conspectus conspectus) { var user = await _userManager.GetUserAsync(HttpContext.User); if (ModelState.IsValid) { conspectus.Id = Guid.NewGuid(); conspectus.UId = user.Id; _context.Add(conspectus); try { await _context.SaveChangesAsync(); return(RedirectToAction("Edit", new { id = conspectus.Id })); } catch (Exception e) { ModelState.AddModelError(string.Empty, "Something went wrong, perhaps the resume name has already been taken. Please try a different resume name."); // ViewBag.Error = "Something went wrong, perhaps the resume name has already been taken. Please try a different resume name."; return(View(conspectus)); } } return(RedirectToAction(nameof(Index))); //return RedirectToAction(nameof(Edit(conspectus.Id))); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,UId,ResumeName, ResumeSlug, UserDisplayName, UserAspiration ,Summary,SummaryName, Experiences, Educations, Skills, Contacts, ExperienceName, EducationName, SkillName, ContactName")] Conspectus conspectus) { if (id != conspectus.Id) { return(NotFound()); } //var test2 = conspectus.Experiences.Count; //Bingo var test1 = conspectus.ResumeName; // works if (ModelState.IsValid) { try { if (conspectus.Experiences != null) { conspectus.Experience = JsonSerializer.Serialize(conspectus.Experiences); var test = conspectus.Experiences[0].Current; } if (conspectus.Educations != null) { conspectus.Education = JsonSerializer.Serialize(conspectus.Educations); } if (conspectus.Skills != null) { conspectus.Skill = JsonSerializer.Serialize(conspectus.Skills); } if (conspectus.Contacts != null) { conspectus.Contact = JsonSerializer.Serialize(conspectus.Contacts); } _context.Update(conspectus); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConspectusExists(conspectus.Id)) { return(NotFound()); } else { throw; } } //return RedirectToAction(nameof(Index)); return(View(conspectus)); } return(View(conspectus)); }