//[ValidateAntiForgeryToken] public ActionResult AssignOnUser(VideoModel vm) { VideoAppPOCEntities2 db = new VideoAppPOCEntities2(); if (ModelState.IsValid) { db.AppVideoUsers.RemoveRange(db.AppVideoUsers.Where(x => x.UserID == vm.UserID)); db.SaveChanges(); foreach (var videoID in vm.videos.Where(x => x.isChecked).Select(x => x.VideoID)) { var appVideoUser = new AppVideoUser { UserID = vm.UserID, VideoID = videoID }; db.AppVideoUsers.Add(appVideoUser); } db.SaveChanges(); TempData["redirectedUserId"] = vm.UserID; return(RedirectToAction("AssignOnUser")); } return(View(vm)); }
public ActionResult upload(AppVideo videoModel) { ViewBag.Message = "this page is for uploading"; string fileName = Path.GetFileNameWithoutExtension(videoModel.VideoFile.FileName); string extension = Path.GetExtension(videoModel.VideoFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; videoModel.VideoPath = "~/Video/" + fileName; fileName = Path.Combine(Server.MapPath("~/Video/"), fileName); videoModel.VideoFile.SaveAs(fileName); using (VideoAppPOCEntities2 db = new VideoAppPOCEntities2()) { db.AppVideos.Add(videoModel); try { db.SaveChanges(); } catch (DbUpdateException e) { Console.WriteLine(e); } } ModelState.Clear(); return(RedirectToAction("LandPage")); }
public ActionResult savevideo(int id, string propertyName, string value) { var status = false; var message = ""; //update data to database using (VideoAppPOCEntities2 dc = new VideoAppPOCEntities2()) { var user = dc.AppVideos.Find(id); if (user != null) { dc.Entry(user).Property(propertyName).CurrentValue = value;//MAKE CHANGE FOR THE AppVideos to AppUsers dc.SaveChanges(); status = true; } else { message = "error!"; } } var response = new { value = value, status = status, message = message }; JObject o = JObject.FromObject(response); return(Content(o.ToString())); }
public ActionResult AssignOnVideo(UserModel um) { VideoAppPOCEntities2 db = new VideoAppPOCEntities2(); if (ModelState.IsValid) { db.AppVideoUsers.RemoveRange(db.AppVideoUsers.Where(x => x.VideoID == um.VideoID)); db.SaveChanges(); foreach (var userID in um.users.Where(x => x.ischecked).Select(x => x.UserID)) { var appVideoUser = new AppVideoUser { UserID = userID, VideoID = um.VideoID }; db.AppVideoUsers.Add(appVideoUser); } db.SaveChanges(); TempData["redirectedVideoId"] = um.VideoID; return(RedirectToAction("AssignOnVideo")); } return(View(um)); }