public List <Models.Video> GetRecomendedVideosByVideo(int videoId) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter = new SqlDataAdapter("Select Distinct V.[id],[title],[description],[username],[discriminator],[videoFile],[thumbnail],[publishedAt]" + " From Video V Join Tag T On T.video = V.id" + " Where T.tag in (select tag from Tag Where video = " + videoId + ") And V.id != " + videoId, connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); List <Models.Video> Videos = new List <Models.Video>(); foreach (DataRow row in dataSet.Tables[0].Rows) { Models.Video video = new Models.Video(); video.id = int.Parse(row["id"].ToString()); video.title = row["title"].ToString(); video.description = row["description"].ToString(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); video.videoFile = row["videoFile"].ToString(); video.thumbnail = row["thumbnail"].ToString(); //video.publishedAt = DateTime.Parse(row["publishedAt"].ToString()); Videos.Add(video); } return(Videos); }
public List <Models.Video> GetVideosByUserId(string userId) { int discriminator = int.Parse(userId.Split('-')[0]); string username = userId.Split('-')[1]; SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter = new SqlDataAdapter( "SELECT * FROM Video Where username='******' And discriminator='" + discriminator + "'", connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); List <Models.Video> Videos = new List <Models.Video>(); foreach (DataRow row in dataSet.Tables[0].Rows) { Models.Video video = new Models.Video(); video.id = int.Parse(row["id"].ToString()); video.title = row["title"].ToString(); video.description = row["description"].ToString(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); video.videoFile = row["videoFile"].ToString(); video.thumbnail = row["thumbnail"].ToString(); video.publishedAt = DateTime.Parse(row["publishedAt"].ToString()); Videos.Add(video); } return(Videos); }
public List <Models.Video> GetVideosSearchByTitle(string search) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter = new SqlDataAdapter( "SELECT * FROM Video Where lower(title) Like '%" + search + "%'" + "Order By (Case When lower(title)='" + search + "' Then 1 When lower(title)='" + search + "%' Then 2 Else 3 End)", connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); List <Models.Video> Videos = new List <Models.Video>(); foreach (DataRow row in dataSet.Tables[0].Rows) { Models.Video video = new Models.Video(); video.id = int.Parse(row["id"].ToString()); video.title = row["title"].ToString(); video.description = row["description"].ToString(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); video.videoFile = row["videoFile"].ToString(); video.thumbnail = row["thumbnail"].ToString(); video.publishedAt = DateTime.Parse(row["publishedAt"].ToString()); Videos.Add(video); } return(Videos); }
public async Task <VideoComment> AddCommentForVideo(Models.Video video) { string reaction; if (_settings.Reactions == null) { reaction = "Best ever video!"; } else { if (_settings.Reactions.Count != 0) { reaction = _settings.Reactions[_random.Next(0, _settings.Reactions.Count - 1)]; } else { reaction = "Best ever video!"; } } var request = _youtubeService.CommentThreads.Insert( new CommentThread { Snippet = new CommentThreadSnippet { ChannelId = video.ChannelId, VideoId = video.VideoId, TopLevelComment = new Comment { Snippet = new CommentSnippet { TextOriginal = reaction } } } }, "snippet"); CommentThread response; try { _logger.LogTrace("Added comment {reaction}", reaction); response = await request.ExecuteAsync(); } catch (Exception e) { _logger.LogError(e.Message); return(null); } return(new VideoComment { Id = response.Snippet.TopLevelComment.Id, AuthorDisplayName = response.Snippet.TopLevelComment.Snippet.AuthorDisplayName, PublishedAt = response.Snippet.TopLevelComment.Snippet.PublishedAt, ETag = response.Snippet.TopLevelComment.Snippet.ETag, TextOriginal = response.Snippet.TopLevelComment.Snippet.TextOriginal, VideoId = video.VideoId }); }
public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, Models.Video video) { _context.Remove(video); _context.SaveChanges(); return(Json(new[] { video }.ToDataSourceResult(request, ModelState))); }
public async Task <IActionResult> PutVideo([FromRoute] int id, [FromBody] Models.Video video) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != video.Id) { return(BadRequest()); } _context.Entry(video).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VideoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Models.Video video = e.Parameter as Models.Video; var Url = await YouTube.GetVideoUriAsync(video.Id, YouTubeQuality.Quality720P); Player.Source = Url.Uri; }
public ActionResult VideoPage(int id) { VideoBll videoBll = new VideoBll(); Models.Video video = videoBll.GetVideoById(id); ViewBag.title = video.title; return(View(video)); }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, Models.Video product) { if (product != null && ModelState.IsValid) { _context.Videos.Update(product); _context.SaveChanges(); } return(Json(new[] { product }.ToDataSourceResult(request, ModelState))); }
public async Task <ActionResult> Create(string channelId) { var video = new Models.Video { ChannelId = channelId }; return(View(video)); }
public ActionResult Create([DataSourceRequest] DataSourceRequest request, Models.Video video) { if (video != null && ModelState.IsValid) { _context.Add(video); _context.SaveChanges(); } return(Json(new[] { video }.ToDataSourceResult(request, ModelState))); }
public async Task <List <Models.VideoComment> > ListCommentsAsync(Models.Video video) { var resultList = new List <VideoComment>(); string nextPageToken = ""; while (nextPageToken != null) { var request = _youtubeService.CommentThreads.List("snippet"); request.MaxResults = 100; request.VideoId = video.VideoId; request.TextFormat = CommentThreadsResource.ListRequest.TextFormatEnum.PlainText; request.PageToken = nextPageToken; CommentThreadListResponse response = null; try { _logger.LogInformation("list comment"); response = await request.ExecuteAsync(); } catch (Exception e) { _logger.LogError(e.Message); if (e.Message.Contains("Request had insufficient authentication scope")) { await _credential.RevokeTokenAsync(CancellationToken.None); await Init(); _logger.LogInformation("list comment"); response = await request.ExecuteAsync(); } } if (response == null) { continue; } resultList.AddRange(response.Items.Select(thread => new VideoComment { Id = thread.Snippet.TopLevelComment.Id, AuthorDisplayName = thread.Snippet.TopLevelComment.Snippet.AuthorDisplayName, PublishedAt = thread.Snippet.TopLevelComment.Snippet.PublishedAt, ETag = thread.Snippet.TopLevelComment.Snippet.ETag, TextOriginal = thread.Snippet.TopLevelComment.Snippet.TextOriginal, VideoId = video.VideoId })); nextPageToken = response.NextPageToken; } return(resultList); }
public async Task SaveVideo(Models.Video video) { if (await VideoById(video.Id) == null) { await VideoAdd(video); } else { await VideoUpdate(video); } }
public List <Models.Video> GetRecomendedVideos(Models.User user) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter = new SqlDataAdapter("Select Top(10) T.tag,COUNT(T.tag) AS 'value_occurrence'" + " From VideoUpvotes VU" + " Join Video V On VU.video = V.id" + " Join Tag T On T.video = V.id" + " Where VU.discriminator = '" + user.discriminator + "'And VU.username = '******'" + " group by T.tag" + " Order by 'value_occurrence' desc", connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); string Commandtext = "Select Distinct Top(10) V.title,Count(VU.video),V.[id],[title],[description],V.[username],V.[discriminator],[videoFile],[thumbnail],[publishedAt] AS 'LikeCount' From Video V Join Tag T On T.video = V.id Join VideoUpvotes VU On VU.video = V.id " + " Where T.tag like '@tag0' Or T.tag like '@tag1' Or T.tag like '@tag2' Or T.tag like '@tag3' Or T.tag like '@tag4' Or T.tag like '@tag5' Or T.tag like '@tag6' Or T.tag like '@tag7' " + "Or T.tag like '@tag8' Or T.tag like '@tag9' Group by V.title, T.tag,V.[id],[title],[description],V.[username],V.[discriminator],[videoFile],[thumbnail],[publishedAt] Order by 'LikeCount'"; for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { Commandtext = Commandtext.Replace("'@tag" + i + "'", "'%" + dataSet.Tables[0].Rows[i]["tag"] + "%'"); } SqlDataAdapter dataAdapter2 = new SqlDataAdapter(Commandtext, connection); DataSet dataSet2 = new DataSet(); dataAdapter2.Fill(dataSet2); List <Models.Video> Videos = new List <Models.Video>(); foreach (DataRow row in dataSet2.Tables[0].Rows) { Models.Video video = new Models.Video(); video.id = int.Parse(row["id"].ToString()); video.title = row["title"].ToString(); video.description = row["description"].ToString(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); video.videoFile = row["videoFile"].ToString(); video.thumbnail = row["thumbnail"].ToString(); //video.publishedAt = DateTime.Parse(row["publishedAt"].ToString()); Videos.Add(video); } return(Videos); }
private async void Button_Click(object sender, RoutedEventArgs e) { try { Button btn = sender as Button; Models.Video video = ListVideo.First(x => x.Id.Equals(btn.Tag)); video.IsLike = true; conn.AddVideo(video); } catch { await new MessageDialog("Something wrong !").ShowAsync(); } }
public void DeleteVideoUpvote(Models.User user, Models.Video video) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = "Delete VideoUpvotes Where video=@video And username=@username And discriminator=@discriminator"; command.Parameters.AddWithValue("video", video.id); command.Parameters.AddWithValue("username", user.username); command.Parameters.AddWithValue("discriminator", user.discriminator); connection.Open(); command.ExecuteNonQuery(); connection.Close(); }
public void CreateVideoUpvote(Models.User user, Models.Video video) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = "INSERT VideoUpvotes(username,discriminator,video) Values (@username,@discriminator,@video)"; command.Parameters.AddWithValue("video", video.id); command.Parameters.AddWithValue("username", user.username); command.Parameters.AddWithValue("discriminator", user.discriminator); connection.Open(); command.ExecuteNonQuery(); connection.Close(); }
public ActionResult Upload(HttpPostedFileBase upload) { if (upload != null) { Random rnd = new Random(); // получаем имя файла Models.Video video = new Models.Video(); string fileName = System.IO.Path.GetFileName(upload.FileName); string nameRnd = fileName.Remove(fileName.Length - 4) + rnd.Next(1, 100000) + ".mp4"; video.Path = Request.PhysicalApplicationPath + "Video\\" + fileName; video.Title = nameRnd; Create(video); upload.SaveAs(Server.MapPath("~/Video/" + nameRnd)); } return(RedirectToAction("Index")); }
public async Task <VideoDataset> InsertVideo(VideoUploadParam upload) { Models.Video video = new Models.Video() { SectionId = upload.SectionId, StyleId = upload.StyleId, AspectRatio = upload.AspectRatio, CoverUrl = upload.CoverUrl, ThumbUrl = upload.ThumbUrl, VideoUrl = upload.VideoUrl }; _uow.VideoRepository.Insert(video); if (await _uow.CommitAsync() > 0) { return(await GetVideoById(video.VideoId)); } return(null); }
public async Task <ActionResult> Create([Bind(Include = "ChannelId,Title,Description")] Models.Video video, HttpPostedFileBase upload) { var accessToken = await AadHelper.GetAccessTokenForSharePoint(); var repo = new VideoChannelRepository(accessToken); // if a file is uploaded, add to video & upload if (upload != null && upload.ContentLength > 0) { video.FileName = upload.FileName; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { video.FileContent = reader.ReadBytes(upload.ContentLength); } await repo.UploadVideo(video); } return(RedirectToRoute("ChannelVideos", new RouteValueDictionary(new { channelId = video.ChannelId, action = "Index" }))); }
{// o video data tem join de outras tabelas(como os upvotes) public Models.Video GetVideoById(int id) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter = new SqlDataAdapter( "SELECT Top(1) * FROM Video Where id=" + id, connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); if (dataSet.Tables.Count <= 0) { return(null); } if (dataSet.Tables[0].Rows.Count <= 0) { return(null); } DataRow row = dataSet.Tables[0].Rows[0]; UserBll userBll = new UserBll(); CommentBll commentBll = new CommentBll(); Models.Video video = new Models.Video(); video.id = id; video.title = row["title"].ToString(); video.description = row["description"].ToString(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); video.videoFile = row["videoFile"].ToString(); video.thumbnail = row["thumbnail"].ToString(); video.publishedAt = DateTime.Parse(row["publishedAt"].ToString()); video.User = userBll.GetUserById(video.discriminator + "-" + video.username); video.comments = commentBll.GetCommentsByVideoId(video.id); video.upvotes = GetVideoUpvotesByVideoId(video.id); video.views = GetVideoViewsByVideoId(video.id); return(video); }
public VideoDetail(Models.Video video) { InitializeComponent(); var htmlSource = new HtmlWebViewSource(); var sourceInfo = @" <html> <head> <title>Test</title> <link href=""https://amp.azure.net/libs/amp/1.8.3/skins/amp-default/azuremediaplayer.min.css"" rel=""stylesheet""> <script src=""https://amp.azure.net/libs/amp/1.8.3/azuremediaplayer.min.js""></script> </head> <body> <video id=""azuremediaplayer"" class=""azuremediaplayer amp-default-skin amp-big-play-centered"" tabindex=""0""></video> <script> var myOptions = { ""nativeControlsForTouch"": false, controls: true, autoplay: true, width: ""640"", height: ""400"", }; myPlayer = amp(""azuremediaplayer"", myOptions); myPlayer.src([ { src: ""{Binding Source}"", type: ""application/vnd.ms-sstr+xml"" } ]); </script> </body> </html> "; htmlSource.Html = sourceInfo.Replace("{Binding Source}", video.VideoUri); browser.Source = htmlSource; }
public async Task <SearchResultViewModel> Search(string searchText, string pageToken) { SearchResource.ListRequest listRequest = youTubeDataApiService.Search.List("snippet"); listRequest.Q = searchText; listRequest.Order = SearchResource.ListRequest.OrderEnum.Relevance; listRequest.SafeSearch = SearchResource.ListRequest.SafeSearchEnum.None; listRequest.RegionCode = "BR"; listRequest.RelevanceLanguage = "PT-BR"; listRequest.Type = "video"; listRequest.MaxResults = 10; listRequest.PageToken = pageToken; SearchListResponse searchResponse = listRequest.Execute(); List <Models.Video> videos = new List <Models.Video>(); foreach (SearchResult searchResult in searchResponse.Items) { var video = new Models.Video() { Id = searchResult.Id.VideoId, Title = searchResult.Snippet.Title, Description = searchResult.Snippet.Description, Url = searchResult.Snippet.Thumbnails.Medium.Url }; videos.Add(video); await SaveVideo(video); } return(new SearchResultViewModel() { nextPageToken = searchResponse.NextPageToken, prevPageToken = searchResponse.PrevPageToken, Videos = await LoadPlaylistsInVideo(videos), Playlists = await repository.PlaylistList() }); }
public Models.Video GetVideoById(string videoId, string apiKey) { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = apiKey, ApplicationName = this.GetType().ToString() }); var videoSearchRequest = youtubeService.Videos.List("snippet,contentDetails,statistics"); videoSearchRequest.Id = videoId; var videoResponse = videoSearchRequest.Execute(); Models.Video videoModel = new Models.Video(); var youtubeVideo = videoResponse.Items.FirstOrDefault(); videoModel.videoId = youtubeVideo.Id; videoModel.videoName = youtubeVideo.Snippet.Title; videoModel.imageUrl60 = youtubeVideo.Snippet.Thumbnails?.Standard?.Url; videoModel.imageUrl90 = youtubeVideo.Snippet.Thumbnails?.Medium?.Url; videoModel.imageUrl120 = youtubeVideo.Snippet.Thumbnails?.High?.Url; return(videoModel); }
public async Task <IActionResult> PostVideo([FromForm] UploadFile model) { var file = model.File; Account account = new Account( "dn2pht7no", "763416155661231", "Y8_D6HDCOUNJAUoPvi8wtVWhkmE"); Cloudinary cloudinary = new Cloudinary(account); if (file.Length > 0) { string path = Path.Combine(_hostingEnvironment.ContentRootPath, @"ClientApp\src\components", "uploadFiles"); using (var fs = new FileStream(Path.Combine(path, file.FileName), FileMode.Create)) { await file.CopyToAsync(fs); } string path2 = Path.Combine(path, file.FileName); var uploadParams = new VideoUploadParams() { File = new FileDescription(path2) }; var uploadResult = cloudinary.Upload(uploadParams); model.source = $"/uploadFiles{file.FileName}"; Models.Video v = new Models.Video(); v.VideoName = file.FileName; v.VideoLink = uploadResult.Uri.ToString(); v.Format = Path.GetExtension(file.FileName).Substring(1).Trim(); _context.Video.Add(v); await _context.SaveChangesAsync(); return(CreatedAtAction("GetVideo", new { id = v.Id }, v)); } return(BadRequest()); }
public ActionResult DownvoteVideo(int id) { if (Session["userId"] is null) { return(new ContentResult() { Content = "Not logged in" }); } Models.User user = new Models.User(); string usernameString = Session["userId"].ToString(); user.discriminator = int.Parse(usernameString.Split('-')[0]); user.username = usernameString.Split('-')[1]; Models.Video video = new Models.Video(); video.id = id; VideoBll videoBll = new VideoBll(); if (videoBll.GetVideoUpvotesByVideoId(id).Where(x => x.username == user.username && x.discriminator == user.discriminator).Count() >= 1) { videoBll.DeleteVideoUpvote(user, video); } else { return new ContentResult() { Content = "false" } }; return(new ContentResult() { Content = "true" }); }
public List <Models.Comment> GetCommentsByVideoId(int id) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); SqlDataAdapter dataAdapter2 = new SqlDataAdapter( "SELECT * FROM Comment Where video=" + id /* + " Order By upvotes Desc"*/ , connection); DataSet dataSet2 = new DataSet(); dataAdapter2.Fill(dataSet2); List <Models.Comment> Comments = new List <Models.Comment>(); foreach (DataRow row in dataSet2.Tables[0].Rows) { Models.Video video = new Models.Video(); video.id = int.Parse(row["video"].ToString()); Models.User user = new Models.User(); video.username = row["username"].ToString(); video.discriminator = int.Parse(row["discriminator"].ToString()); Models.Comment comment = new Models.Comment(); comment.id = int.Parse(row["id"].ToString()); comment.comment = row["comment"].ToString(); comment.video = video; comment.user = user; comment.username = row["username"].ToString(); comment.discriminator = int.Parse(row["discriminator"].ToString()); //comment.createdAt = DateTime.Parse(row["createdAt"].ToString()); Comments.Add(comment); } return(Comments); }
public ActionResult PostVideo(HttpPostedFileBase file, Models.Video video, string tags) { Models.User user = new Models.User(); user.username = Session["userId"].ToString().Split('-')[1]; user.discriminator = int.Parse(Session["userId"].ToString().Split('-')[0]); foreach (string tagtext in tags.Split(' ').ToList()) { Models.Tag tag = new Tag(); tag.text = tagtext; video.tags.Add(tag); } //video.title = Request.QueryString.Get("title"); //video.description = Request.QueryString.Get("description"); video.thumbnail = "defaultthumbnail.png"; if (file != null && file.ContentLength > 0) { try { string path = Path.Combine(Server.MapPath("../videos"), Path.GetFileName(file.FileName)); file.SaveAs(path); ViewBag.Message = "File uploaded successfully"; video.videoFile = file.FileName; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); video.VideoUploadError = "ERROR:" + ex.Message.ToString(); return(new ContentResult() { Content = "ERROR:" + ex.Message.ToString() }); } } else { ViewBag.Message = "You have not specified a file."; video.VideoUploadError = "You have not specified a file."; return(new ContentResult() { Content = "You have not specified a file." }); } VideoBll videoBll = new VideoBll(); video = videoBll.CreateVideo(user, video); return(RedirectToAction("VideoPage", "Home", new { id = video.id })); return(new ContentResult() { Content = "Video posted" }); }
public async Task VideoUpdate(Models.Video video) { await repository.VideoUpdate(video); }
public ActionResult Upload(string name, string description, HttpPostedFileBase video) { Models.Video v = new Models.Video(); v.Date = DateTime.Now; v.Name = name; v.Description = description; v.Link = Guid.NewGuid().ToString().Replace("-", ""); v.UserId = new Guid(Membership.GetUser().ProviderUserKey.ToString()); string ext = Path.GetExtension(video.FileName).ToLower(); video.SaveAs(Server.MapPath("~/Videos/"+v.Link+ext)); Models.YoyoEntities db = new Models.YoyoEntities(); db.Videos.Add(v); db.SaveChanges(); Microsoft.Expression.Encoder.AudioVideoFile audiovideo = new Microsoft.Expression.Encoder.AudioVideoFile(Server.MapPath("~/Videos/" + v.Link + ext)); TimeSpan dur = audiovideo.Duration; int second = 1; int step = dur.Seconds / 5; for (int i = 1; i <= 5; i++) { int sc = second; int h = second / 3600; sc = sc - h * 3600; int m = sc / 60; sc = sc - m * 60; int s = sc; Bitmap bmp = audiovideo.GetThumbnail(new TimeSpan(h,m,s), new System.Drawing.Size(800, 600)); bmp.Save(Server.MapPath("~/VideosPictures/" + v.Link+"_"+i + ".png"), ImageFormat.Png); second += step; } return RedirectToAction("Index"); }
public Models.Video CreateVideo(Models.User user, Models.Video video) { SqlConnection connection = new SqlConnection(Properties.Settings.Default.Connection); //SqlCommand command = new SqlCommand(); //command.Connection = connection; //command.CommandType = CommandType.Text; //command.CommandText = "INSERT Video(title,description,username,discriminator,publishedAt,videoFile,thumbnail) Values (@title,@description,@username,@disc,@date,@file,@thumbnail)"; //command.Parameters.AddWithValue("title", video.title); //command.Parameters.AddWithValue("username", user.username); //command.Parameters.AddWithValue("disc", user.discriminator); //command.Parameters.AddWithValue("date", DateTime.Now); //command.Parameters.AddWithValue("file", video.videoFile); //command.Parameters.AddWithValue("thumbnail", video.thumbnail); //command.Parameters.AddWithValue("description", video.description); //command.Parameters.AddWithValue("description", video.tags); //connection.Open(); //command.ExecuteNonQuery(); //connection.Close(); string com = "INSERT Video(title,description,username,discriminator,publishedAt,videoFile,thumbnail) Output inserted.id Values (@title,@description,@username,@disc,@date,@file,@thumbnail)"; //com = com.Replace("@title", video.title); //com = com.Replace("@username", user.username); //com = com.Replace("@disc", user.discriminator.ToString()); //com = com.Replace("@date", DateTime.Now.ToString()); //com = com.Replace("@file", video.videoFile); //com = com.Replace("@thumbnail", video.thumbnail); //com = com.Replace("@description", video.description); SqlDataAdapter dataAdapter = new SqlDataAdapter(com, connection); //dataAdapter.InsertCommand = command; //dataAdapter.InsertCommand.CommandText = com; //dataAdapter.InsertCommand.CommandType = CommandType.Text; dataAdapter.SelectCommand.Parameters.AddWithValue("title", video.title); dataAdapter.SelectCommand.Parameters.AddWithValue("username", user.username); dataAdapter.SelectCommand.Parameters.AddWithValue("disc", user.discriminator); dataAdapter.SelectCommand.Parameters.AddWithValue("date", DateTime.Now); dataAdapter.SelectCommand.Parameters.AddWithValue("file", video.videoFile); dataAdapter.SelectCommand.Parameters.AddWithValue("thumbnail", video.thumbnail); dataAdapter.SelectCommand.Parameters.AddWithValue("description", video.description); //dataAdapter.InsertCommand.Connection = connection; DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); DataRow row = dataSet.Tables[0].Rows[0]; video.id = int.Parse(row["id"].ToString()); foreach (Models.Tag tag in video.tags) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = "INSERT Tag(video,tag) Values (@video,@tag)"; command.Parameters.AddWithValue("video", video.id); command.Parameters.AddWithValue("tag", tag.text); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } return(video); }