public IActionResult Create(VideoEditViewModel model) { var video = new Video { Title = model.Title, Genre = model.Genre }; _videos.Add(video); return(RedirectToAction("Details", new { id = video.Id })); }
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 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 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()); }
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()); }