public ActionResult Create([Bind(Include = "VideoId,Name,Link")] Video video) { var loggedinuser = Session["bhuinfologgedinuser"] as AppUser; if (ModelState.IsValid) { if (loggedinuser != null) { video.DateCreated = DateTime.Now; video.DateLastModified = DateTime.Now; video.CreatedById = loggedinuser.AppUserId; video.LastModifiedById = loggedinuser.AppUserId; db.Videos.Add(video); db.SaveChanges(); TempData["video"] = "You have successfully added a new video!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); } else { TempData["login"] = "******"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } } return(View(video)); }
public IActionResult Create(Video model) { if (ModelState.IsValid) { _db.Videos.Add(model); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }