public IActionResult Edit(EditInternBindingModel bm, int id) { var intern = InternServices.GetInternById(id); if (!ModelState.IsValid) { var comapnies = CompanyServices.GetAllCompanies(); var internDto = new EditInternDto() { Intern = intern, Companies = comapnies }; return(this.View(internDto)); } EditIntern(bm, intern); this.InternServices.UpdateIntern(intern); var companies = this.CompanyServices.GetAllCompanies(); intern = InternServices.GetInternById(id); var dto = new EditInternDto() { Intern = intern, Companies = companies }; this.ViewData["edit"] = "You have successfully edited this intern!"; return(this.View(dto)); }
public IActionResult Edit(int id, string slug) { var intern = InternServices.GetInternById(id); var comapnies = CompanyServices.GetAllCompanies(); if (intern == null || intern.Name != slug) { return(NotFound()); } var internDto = new EditInternDto() { Intern = intern, Companies = comapnies }; return(this.View(internDto)); }