public IActionResult Create(VideoEditViewModel model) { if (ModelState.IsValid) { var video = new Video { Title = model.Title, Genre = model.Genre }; _videos.Add(video); _videos.Commit(); return(RedirectToAction("Details", new { Id = video.Id })); } return(View()); }
public IActionResult Edit(int id, VideoEditViewModel model) { var video = _videos.Get(id); if (video == null || !ModelState.IsValid) { return(View(model)); } video.Title = model.Title; video.Genre = model.Genre; _videos.Commit(); return(RedirectToAction("Details", new { id = video.Id })); }
public IActionResult Create(VideoEditViewModel model) // using VideoEditViewModel as the model to base the fields for the form on { if (ModelState.IsValid) { var video = new Video // Here we match the form inputs to the respective properties in the ViewModel { Title = model.Title, Genre = model.Genre }; _videos.Add(video); _videos.Commit(); return(RedirectToAction("Details", new { id = video.Id })); } return(View()); }
public IActionResult Create(VideoEditViewModel model) { if (ModelState.IsValid) { var video = new Video { Title = model.Title, Genre = model.Genre }; _videos.Add(video); // Add is the method from IVideoData --- void Add(Video newVideo); _videos.Commit(); // ??? return(RedirectToAction("Details", new { id = video.Id })); } return(View()); }
public IActionResult OnPost(int vidId) { var confirmdelete = deleteVideo.GetVideosById(vidId); if (confirmdelete == null) { return(Page()); } deleteVideo.Delete(vidId); deleteVideo.Commit(); return(RedirectToPage("./VideosList")); }
public IActionResult OnPost(Videos VideoDetails) { if (VidImage != null) { VideoDetails.VideoImage = UploadedImage(VidImage); } if (ModelState.IsValid) { Message = addVideo.Add(VideoDetails); if (Message == "New Video Added") { addVideo.Commit(); return(RedirectToPage("./VideosList")); } } return(Page()); }