// GET: Directors/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Directors directors = db.Directors.Find(id); if (directors == null) { return(HttpNotFound()); } var model = new DirectorsModel() { Id = directors.Id, Name = directors.Name, Surname = directors.Surname, RetiredText = directors.Retired ? "Yes" : "No" }; var viewModel = new DirectorsDetailsViewModel() { Director = model, Title = _detailTitle }; return(View(viewModel)); }
// GET: Directors/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Directors directors = db.Directors.Find(id); if (directors == null) { return(HttpNotFound()); } var model = new DirectorsModel() { Id = directors.Id, Name = directors.Name, Surname = directors.Surname, RetiredText = directors.Retired ? "Yes" : "No" }; // _detailsTitle = "Mert"; // const kullanımı için örnek: Değişken const olarak tanımlandığı için hiç bir şekilde değiştirilemez... var viewModel = new DirectorsDetailsViewModel() { Director = model, Title = _detailTitle // const kullanımı için örnek }; return(View(viewModel)); }
public IActionResult Details(int id) { var director = this.context .Directors .FirstOrDefault(d => d.Id == id); if (director == null) { return(this.RedirectToAction("All", "Movies")); } this.DetailsModel = new DirectorsDetailsViewModel { Director = director.Name }; this.DetailsModel.Movies = this.context .Movies .Where(m => m.DirectorId == id) .Select(m => new DirectorsMoviesViewModel { MovieId = m.Id, Title = m.Title }) .ToList(); return(this.View(this.DetailsModel)); }