public IActionResult Edit(int id) { var repo = new JobOffersRepository(); var item = repo.GetById(id); if (item == null) { return(View(new JobOfferEditVM())); } var editVM = new JobOfferEditVM() { ID = item.ID, CreatorId = item.ID, Title = item.Title, Description = item.Description }; return(View(editVM)); }
public IActionResult Edit(JobOfferEditVM model) { if (!ModelState.IsValid) { return(View(model)); } var repo = new JobOffersRepository(); var item = repo.GetById(model.ID); if (item == null) { item = new Models.JobOffer(); item.CreatorId = AuthService.LoggedUser.ID; } item.Title = model.Title; item.Description = model.Description; repo.Save(item); return(RedirectToAction("List")); }