public async Task <IActionResult> Edit(int id, [Bind("VideoNewsId,Title,Category,Keyword,Datetime,Path")] Videonews videonews) { if (id != videonews.VideoNewsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(videonews); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VideonewsExists(videonews.VideoNewsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(videonews)); }
public async Task <IActionResult> Create([Bind("VideoNewsId,Title,Category,Keyword,Datetime,Path")] Videonews videonews) { //if (ModelState.IsValid) //{ // _context.Add(videonews); // await _context.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); //} //return View(videonews); if (ModelState.IsValid) { var ckcategory = _context.Videonews.Where(c => c.VideoNewsId == videonews.VideoNewsId).Count(); if (ckcategory > 0) { ModelState.AddModelError("", "This Video News ID " + videonews.VideoNewsId + " is alredy exists!"); } else { _context.Add(videonews); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(videonews)); }
public string ActivatePicture(int id, string path) { string a = "1"; Videonews st = (from s in _context.Videonews where s.VideoNewsId == id select s).First(); st.Path = path; _context.SaveChanges(); return(a); }
public ActionResult UploadFile(IFormFile file, int id) { try { if (file == null || file.Length == 0) { return(Content("file not selected")); } if (file.Length > 0) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Videos/" + file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { file.CopyTo(stream); } Videonews st = (from s in _context.Videonews where s.VideoNewsId == id select s).First(); st.Path = file.FileName; _context.SaveChanges(); int psl = (from ip in _context.Allvideo where ip.VideoId == id orderby ip.VideoSerial descending select ip.VideoId).FirstOrDefault(); psl++; Allvideo ipc = new Allvideo(); ipc.VideoId = id; ipc.VideoSerial = psl.ToString(); ipc.VideoPath = file.FileName; _context.Add(ipc); _context.SaveChanges(); } ViewBag.Message = "File Uploaded Successfully!!" + ":" + id; return(RedirectToAction("Index")); } catch { ViewBag.Message = "File upload failed!!"; return(View()); } }