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 async Task <IActionResult> Edit(int id, [Bind("Id,Name,Video,AppId")] AppVideo appVideo) { if (id != appVideo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(appVideo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppVideoExists(appVideo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AppId"] = new SelectList(_context.Apps, "Id", "DeveloperName", appVideo.AppId); return(View(appVideo)); }
public ActionResult ViewVideo(int id) { AppVideo videoModel = new AppVideo(); using (VideoAppPOCEntities2 db = new VideoAppPOCEntities2()) { videoModel = db.AppVideos.Where(x => x.VideoID == id).FirstOrDefault(); } return(View(videoModel)); }
public async Task <IActionResult> Create([Bind("Id,Name,Video")] AppVideo appVideo) { if (ModelState.IsValid) { appVideo.AppId = 1; //default before change in app's create _context.Add(appVideo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AppId"] = new SelectList(_context.Apps, "Id", "Name"); return(View(appVideo)); }