public ActionResult UploadFile() { var httpPostedFile = Request.Files[0]; if (httpPostedFile != null) { // Validate the uploaded file if you want like content length(optional) // Get the complete file path /* var uploadFilesDir = System.Web.HttpContext.Current.Server.MapPath("~/Videos"); * if (!Directory.Exists(uploadFilesDir)) * { * Directory.CreateDirectory(uploadFilesDir); * } * var fileSavePath = Path.Combine(uploadFilesDir, httpPostedFile.FileName);*/ // Save the uploaded file to "UploadedFiles" folder // httpPostedFile.SaveAs(fileSavePath); VideoRepository rep = new VideoRepository(); rep.Add(httpPostedFile); } return(RedirectToAction("Index"));//Content("Uploaded Successfully"); }
public static void UpdateChannel(string channelId) { var playlistId = YouTubeApi.GetUploadsPlaylistId(channelId); var newItems = YouTubeApi.PlaylistItemsByPlaylistId(playlistId) .Except(videos.Get().Select(v => v.VideoId)); foreach (var newItem in newItems) { videos.Add(newItem); } }
public ActionResult Create(Video video) { try { if (!ModelState.IsValid) { return(View(video)); } repository.Add(video); repository.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void AddVideo() { var options = new DbContextOptionsBuilder <BetterCalmContext>() .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options; var context = new BetterCalmContext(options); context.Add(listVideo[0]); context.SaveChanges(); repository = new VideoRepository(context); var initial = repository.GetAll().Count(); repository.Add(listVideo[1]); var final = repository.GetAll().Count(); context.Database.EnsureDeleted(); Assert.AreEqual(initial + 1, final); }