public ActionResult DeleteConfirmed(int id) { ProjectVideo projectVideo = db.ProjectVideos.Find(id); db.ProjectVideos.Remove(projectVideo); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,IsMainVideo,Name,Description,URL,ProjectId")] ProjectVideo projectVideo) { if (ModelState.IsValid) { db.Entry(projectVideo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.ProjectId = new SelectList(db.Proj, "Id", "Title", projectVideo.ProjectId); return(View(projectVideo)); }
public async Task <HttpResponseMessage> Post(string id, ProjectVideoModel model) { // Check whether project with such id exists await GetProjectAsync(id); // Add video to that project var video = new DomainVideo { FileName = model.Video.Name, FileUri = model.Video.Uri, ContentType = model.Video.ContentType, FileLength = model.Video.Length }; try { video = await _videoRepository.AddAsync(id, video); } catch (AggregateException aggregateException) { // Handle VideoFormatExceptions var errorsList = new StringBuilder(String.Format("{0}\n", aggregateException.Message)); foreach (Exception exception in aggregateException.InnerExceptions) { var videoFormatException = exception as VideoFormatException; if (videoFormatException == null) { Trace.TraceError("Failed to add a video file: {0}", exception); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ResponseMessages.InternalServerError)); } string errorMessage = GetExceptionDescription(videoFormatException.ParamType); errorsList.AppendLine(errorMessage); ModelState.AddModelError("Video", errorMessage); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var projectVideo = new ProjectVideo { Name = video.FileName, Uri = video.FileUri, ContentType = video.ContentType, Length = video.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, projectVideo); response.SetLastModifiedDate(video.Modified); return(response); }
// GET: ProjectVideos/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectVideo projectVideo = db.ProjectVideos.Find(id); if (projectVideo == null) { return(HttpNotFound()); } return(View(projectVideo)); }
// GET: ProjectVideos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectVideo projectVideo = db.ProjectVideos.Find(id); if (projectVideo == null) { return(HttpNotFound()); } //ViewBag.ProjectId = new SelectList(db.Proj, "Id", "Title", projectVideo.ProjectId); return(View(projectVideo)); }
// GET api/projects/{id}/video public async Task<HttpResponseMessage> Get(string id) { // Get project await GetProjectAsync(id); DomainVideo video = await _videoService.GetAsync(id); var projectVideo = new ProjectVideo { Name = video.FileName, Uri = video.FileUri, ContentType = video.ContentType, Length = video.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, projectVideo); response.SetLastModifiedDate(video.Modified); return response; }
// GET api/projects/{id}/video public async Task <HttpResponseMessage> Get(string id) { // Get project await GetProjectAsync(id); DomainVideo video = await _videoService.GetAsync(id); var projectVideo = new ProjectVideo { Name = video.FileName, Uri = video.FileUri, ContentType = video.ContentType, Length = video.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, projectVideo); response.SetLastModifiedDate(video.Modified); return(response); }
public static DataAccessAction <ProjectVideo> SetVideoForProject(int projectId, int videoReferenceId) { return(new DataAccessAction <ProjectVideo>((IDbConnection conn) => { Guard.This(conn.Get <Project>(projectId)).AgainstDefaultValue(string.Format("Project with id '{0}' does not exist", projectId)); Guard.This(conn.Get <VideoReference>(videoReferenceId)).AgainstDefaultValue(string.Format("Video reference with id '{0}' does not exist", videoReferenceId)); var existingProjectVideos = conn.Query <ProjectVideo>("SELECT * FROM ProjectVideo WHERE projectid = @projectid", new { projectId }); using (var transaction = conn.BeginTransaction()) { try { var nextProjectVideoId = conn.GetNextId <ProjectVideo>(); foreach (var existingProjectVideo in existingProjectVideos) { conn.Delete(existingProjectVideo, transaction); } var projectVideo = new ProjectVideo(); projectVideo.Id = nextProjectVideoId; projectVideo.ProjectId = projectId; projectVideo.VideoReferenceId = videoReferenceId; conn.Insert(projectVideo, transaction); transaction.Commit(); return projectVideo; } catch { transaction.Rollback(); throw; } } })); }
private void OnEnable() { _projectVideo = GetComponent <ProjectVideo>(); }
protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e) { try { if (e.CommandName == "PerformInsert" || e.CommandName == "Update") { var item = e.ListViewItem; var FileImagePath = (RadUpload)item.FindControl("FileImagePath"); var FileVideoPath = (RadUpload)item.FindControl("FileVideoPath"); string strProjectVideoID; var strProjectID = Request.QueryString["PI"]; var strProjectTitle = ((Label)FormView1.FindControl("lblProjectTitle")).Text.Trim(); var strConvertedProjectTitle = Common.ConvertTitle(strProjectTitle); var strImagePath = FileImagePath.UploadedFiles.Count > 0 ? FileImagePath.UploadedFiles[0].GetName() : ""; var strVideoPath = FileVideoPath.UploadedFiles.Count > 0 ? FileVideoPath.UploadedFiles[0].GetName() : ""; var strTitle = ((TextBox)item.FindControl("txtTitle")).Text.Trim(); var strDescription = ((TextBox)item.FindControl("txtDescription")).Text.Trim(); var strTitleEn = ((TextBox)item.FindControl("txtTitleEn")).Text.Trim(); var strDescriptionEn = ((TextBox)item.FindControl("txtDescriptionEn")).Text.Trim(); var strIsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); var strPriority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim(); var oProjectVideo = new ProjectVideo(); if (e.CommandName == "PerformInsert") { strProjectVideoID = oProjectVideo.ProjectVideoInsert( strTitle, strDescription, strTitleEn, strDescriptionEn, strConvertedProjectTitle, strImagePath, strVideoPath, strProjectID, strIsAvailable, strPriority).ToString(); RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None; } else { strProjectVideoID = ((HiddenField)item.FindControl("hdnProjectVideoID")).Value; var strOldImagePath = ((HiddenField)item.FindControl("hdnImagePath")).Value; var strOldVideoPath = ((HiddenField)item.FindControl("hdnProjectVideoPath")).Value; var dsUpdateParam = ObjectDataSource1.UpdateParameters; if (!string.IsNullOrEmpty(strVideoPath)) { strOldVideoPath = Server.MapPath("~/res/project/video/" + strOldVideoPath); if (File.Exists(strOldVideoPath)) { File.Delete(strOldVideoPath); } } if (!string.IsNullOrEmpty(strImagePath)) { strOldImagePath = Server.MapPath("~/res/project/video/thumbs/" + strOldImagePath); if (File.Exists(strOldImagePath)) { File.Delete(strOldImagePath); } } dsUpdateParam["ImagePath"].DefaultValue = strImagePath; dsUpdateParam["ProjectVideoPath"].DefaultValue = strVideoPath; dsUpdateParam["ConvertedTitle"].DefaultValue = strConvertedProjectTitle; } string strFullVideoPath = "~/res/project/video/" + (string.IsNullOrEmpty(strConvertedProjectTitle) ? "" : strConvertedProjectTitle + "-") + strProjectVideoID + Path.GetExtension(strVideoPath); string strFullImagePath = "~/res/project/video/thumbs/" + (string.IsNullOrEmpty(strConvertedProjectTitle) ? "" : strConvertedProjectTitle + "-") + strProjectVideoID + Path.GetExtension(strImagePath); if (!string.IsNullOrEmpty(strVideoPath)) { FileVideoPath.UploadedFiles[0].SaveAs(Server.MapPath(strFullVideoPath)); } if (!string.IsNullOrEmpty(strImagePath)) { FileImagePath.UploadedFiles[0].SaveAs(Server.MapPath(strFullImagePath)); ResizeCropImage.ResizeByCondition(strFullImagePath, 600, 600); } } else if (e.CommandName == "Delete") { var strOldImagePath = ((HiddenField)e.ListViewItem.FindControl("hdnImagePath")).Value; DeleteImage(strOldImagePath); } else if (e.CommandName == "QuickUpdate") { string ProjectVideoID, Priority, IsAvailable; var oProjectVideo = new ProjectVideo(); foreach (RadListViewDataItem item in RadListView1.Items) { ProjectVideoID = item.GetDataKeyValue("ProjectVideoID").ToString(); Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim(); IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); oProjectVideo.ProjectVideoQuickUpdate( ProjectVideoID, IsAvailable, Priority ); } } else if (e.CommandName == "DeleteSelected") { var oProjectVideo = new ProjectVideo(); string ProjectVideoID, OldImagePath, OldVideoPath; foreach (RadListViewDataItem item in RadListView1.Items) { var chkSelect = (CheckBox)item.FindControl("chkSelect"); if (chkSelect.Checked) { ProjectVideoID = item.GetDataKeyValue("ProjectVideoID").ToString(); OldImagePath = ((HiddenField)item.FindControl("hdnImagePath")).Value; OldVideoPath = ((HiddenField)item.FindControl("hdnVideoPath")).Value; DeleteImage(OldImagePath); DeleteVideo(OldVideoPath); oProjectVideo.ProjectVideoDelete(ProjectVideoID); } } } RadListView1.Rebind(); } catch (Exception ex) { lblError.Text = ex.Message; } }
public async Task<HttpResponseMessage> Post(string id, ProjectVideoModel model) { // Check whether project with such id exists await GetProjectAsync(id); // Add video to that project var video = new DomainVideo { FileName = model.Video.Name, FileUri = model.Video.Uri, ContentType = model.Video.ContentType, FileLength = model.Video.Length }; try { video = await _videoRepository.AddAsync(id, video); } catch (AggregateException aggregateException) { // Handle VideoFormatExceptions var errorsList = new StringBuilder(String.Format("{0}\n", aggregateException.Message)); foreach (Exception exception in aggregateException.InnerExceptions) { var videoFormatException = exception as VideoFormatException; if (videoFormatException == null) { Trace.TraceError("Failed to add a video file: {0}", exception); return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ResponseMessages.InternalServerError); } string errorMessage = GetExceptionDescription(videoFormatException.ParamType); errorsList.AppendLine(errorMessage); ModelState.AddModelError("Video", errorMessage); } return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } var projectVideo = new ProjectVideo { Name = video.FileName, Uri = video.FileUri, ContentType = video.ContentType, Length = video.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, projectVideo); response.SetLastModifiedDate(video.Modified); return response; }
// [Route("ProjectVideoController/Add")] //[WriteLog(EComLib_ActionEnum.新增)] public async Task <IActionResult> Add([FromBody] ProjectVideo model) { throw new NotImplementedException(); }