public IActionResult Create() { var model = new CreateExperienceForm(); Populate(model); return(View(model)); }
public IActionResult Create(CreateExperienceForm form) { if (!ModelState.IsValid) { Populate(form); return(View(form)); } var experience = new Experience { Description = form.Description }; _experienceRepository.Add(experience); return(RedirectToAction("Details", new { id = experience.Id })); }
private void Populate(CreateExperienceForm form) { var users = _userRepository.GetAll(); form.Users = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(users, nameof(Domain.Users.User.Id), nameof(Domain.Users.User.Name)); }