示例#1
0
        public JsonResult Delete(int id)
        {
            var target = _VideoService.Delete(id);

            _VideoService.Save();
            return(Json(new
            {
                message = ResultState.Delete_SUCCESS
            }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public override void DeleteByExistingId()
        {
            var existingId = MockVideoBO.Id;

            MockVideoRepository.Setup(r => r.GetById(existingId)).Returns(MockVideo);
            MockVideoRepository.Setup(r => r.Delete(existingId)).Returns(true);

            var deleted = _service.Delete(existingId);

            Assert.True(deleted);
        }
        public ActionResult Delete(long id)
        {
            try
            {
                var oldVideo = db.GetVideo(id);

                if (oldVideo.UserName != UserHelper.Instance.CurrentUserName)
                {
                    return(new HttpStatusCodeResult(405, "Unauthorized text delete"));
                }

                db.Delete(id);

                if (Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri != null)
                {
                    return(new RedirectResult(Request.UrlReferrer.AbsoluteUri));
                }
                else
                {
                    return(RedirectToAction("Index", "Manage"));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(HttpNotFound());
            }
        }
示例#4
0
        public void Delete(int id)
        {
            var video = _videoService.GetById(id);

            //remove video from album
            var albums = _albumService.GetAll();

            foreach (var album in albums)
            {
                var videos         = album.idVideo.Split('|').Where(x => x != id.ToString()).ToArray();
                var newAlbumVideos = "";
                foreach (var v in videos)
                {
                    newAlbumVideos = string.Concat(newAlbumVideos, v, "|");
                }
                var newAlbum = new AlbumModel();
                if (newAlbumVideos.Length > 0)
                {
                    newAlbum.idVideo = newAlbumVideos.Remove(newAlbumVideos.Length - 1);
                }
                else
                {
                    newAlbum.idVideo = "";
                }
                newAlbum.idImmagini = album.idImmagini;
                _albumService.Update(album.id, newAlbum);
            }

            var filePath = "Content\\Videos\\" + video.name;

            _fileService.Delete(filePath);
            _videoService.Delete(id);
        }
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _videoService.Delete(id);

            if (result > 0)
            {
                return(Content("Success"));
            }
            return(Content("Error"));
        }
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _videoService.Delete(id);

            if (result > 0)
            {
                return(Ok());
            }
            return(BadRequest("Delete No Success"));
        }
示例#7
0
        public IActionResult Delete(string id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(Result.Failed));
            }
            var item = service.Delete(id);

            return(Ok(item));
        }
示例#8
0
        public async Task <IActionResult> Delete(string id)
        {
            var result = await _videoService.Delete(CurrentUser.TenantId, id);

            if (result.Code <= 0)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public IActionResult Delete([FromForm] int id)
        {
            var result = _videoService.Delete(id);

            if (result.Succcess)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
        public void DeleteVideo()
        {
            Console.Clear();

            Console.WriteLine("You chose option 3 : Delete video.");
            Console.WriteLine("");
            Console.WriteLine("What video id do you want to delete?");
            int   videoToDeleteId = int.Parse(Console.ReadLine());
            Video deletedVideo    = _videoService.Delete(videoToDeleteId);

            Console.WriteLine($"Video with id: {deletedVideo.Id} was deleted.");
        }
示例#11
0
        public ActionResult <Video> DeleteVideo([FromRoute] Guid id)
        {
            var Video = _videoService.Find(id);

            if (Video == null)
            {
                return(NotFound());
            }

            _videoService.Delete(Video);
            return(Video);
        }
示例#12
0
 public async Task <ActionResult> DeleteVideo(int id)
 {
     try
     {
         await _videoService.Delete(id);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
     return(Ok());
 }
        public ActionResult <Video> DeleteVideo(int id)
        {
            var Video = videoService.GetVideoById(id);

            if (Video == null)
            {
                return(NotFound());
            }

            videoService.Delete(Video);
            return(Video);
        }
示例#14
0
        public ActionResult Delete(Video video)
        {
            Video  vid  = videoService.Get(video.Id);
            string tmp  = Path.Combine(Server.MapPath(vid.Poster.ToString())).ToString();
            string tmp2 = Path.Combine(Server.MapPath(vid.VideoURL.ToString())).ToString();


            System.IO.File.Delete(tmp);
            System.IO.File.Delete(tmp2);
            videoService.Delete(video.Id);

            return(RedirectToAction("AllVideo", "Video", new { id = video.ChannelId }));
        }
 public IActionResult Delete([FromBody] int data)
 {
     try
     {
         var userData = jwtService.ParseData(this.User);
         var result   = videoService.Delete(data, userData.UserId);
         return(Ok(result));
     }
     catch (ServiceException e)
     {
         return(BadRequest(e.Message));
     }
 }
        public JsonResult VideoDelete(string id)
        {
            var model = _videoServer.QueryWhere(t => t.Id == id);

            if (!string.IsNullOrWhiteSpace(id))
            {
                _videoServer.Delete(id);
                LogRecord.WriteServiceLog("admin", "admin删除成功" + model.VideoName + "视频", "warnning");
                return(Json(JsonHandler.CreateMessage(1, Suggestion.DeleteSucceed)));
            }
            else
            {
                LogRecord.WriteServiceLog("admin", "admin删除失败" + model.VideoName + "视频", "normal");
                return(Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail)));
            }
        }
示例#17
0
        public IActionResult DeleteVideo(long id)
        {
            VideoDTO videoDto;

            try
            {
                videoDto = _videoService.GetById(id);
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }

            _videoService.Delete(videoDto);

            return(Ok());
        }
示例#18
0
        public ActionResult Delete(int id)
        {
            if (!_permissionService.Authorize("ManageVideos"))
            {
                return(AccessDeniedView());
            }

            if (id == 0)
            {
                throw new Exception("Id Not Found");
            }

            _videoService.Delete(id);

            SuccessNotification("Video deleted successfully.");
            return(RedirectToAction("List"));
        }
        public ActionResult <SuccessResponse> Delete(int id)
        {
            int          code     = 200;
            BaseResponse response = null;//do not declare an instance.

            try
            {
                _service.Delete(id);

                response = new SuccessResponse();
            }
            catch (Exception ex)
            {
                code     = 500;
                response = new ErrorResponse(ex.Message);
            }

            return(StatusCode(code, response));
        }
示例#20
0
        public JsonResult Delete(int id = 0)
        {
            try
            {
                var entity = _videoService.GetById(id);

                if (entity == null)
                {
                    return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet));
                }

                _videoService.Delete(entity);

                return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }
示例#21
0
        public async Task <ActionResult <Video> > Delete(
            int id,
            [FromServices] IVideoService VideoService)
        {
            try
            {
                var video = await VideoService.GetById(id);

                if (video == null)
                {
                    return(NotFound(new { message = Messages.VIDEO_NAO_ENCONTRADO }));
                }

                await VideoService.Delete(video);

                return(Ok(new { message = Messages.VIDEO_REMOVIDO_COM_SUCESSO }));
            }
            catch
            {
                return(BadRequest(new { message = Messages.OCORREU_UM_ERRO_INESPERADO }));
            }
        }
示例#22
0
        public async Task <IActionResult> UploadVideo(int?id, IFormFile file)
        {
            try
            {
                if (id == null)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new Response <dynamic> {
                        Succeeded = false, Message = "آیتم مورد نظر پیدا نشد"
                    }));
                }
                var center = _centerService.GetById(id.Value);

                if (center == null)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new Response <dynamic> {
                        Succeeded = false, Message = "آیتم مورد نظر پیدا نشد"
                    }));
                }
                if (file == null || file.Length <= 0)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new Response <dynamic> {
                        Succeeded = false, Message = "ویدیو پیدا نشد"
                    }));
                }

                var uploadFolder = Path.Combine(Directory.GetCurrentDirectory(), "UploadedFiles", "Videos");

                if (!Directory.Exists(uploadFolder))
                {
                    Directory.CreateDirectory(uploadFolder);
                }
                var fileName  = id + "-(" + DateTime.Now.ToString("yyyy-M-d-hhmmss") + ")" + Path.GetExtension(file.FileName);
                var finalPath = Path.Combine(uploadFolder, fileName);

                await using (var fileStream = new FileStream(finalPath, FileMode.Create))
                {
                    await file.CopyToAsync(fileStream);
                }
                var video = _videoService.AddVideo(id.Value, fileName);

                var conversionHelper = new ConversionHelper(_videoService);
                _backgroundJob.Enqueue(() => conversionHelper.ConvertVideo(video));

                var oldVideo = _videoService.GetByCenterId(id.Value);
                if (oldVideo != null)
                {
                    _videoService.Delete(oldVideo);
                    var videoConverts = _videoService.GetVideoConverts(oldVideo.Id);
                    foreach (var item in videoConverts)
                    {
                        _videoService.DeleteVideoConvert(item.Id);
                    }
                }
                return(Ok(new Response <dynamic>(finalPath)
                {
                    Message = "ویدیو با موفقیت آپلود شد"
                }));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response <dynamic> {
                    Succeeded = false, Message = e.ToString() + "آپلود ویدیو با خطا مواجه شد"
                }));
            }
        }
示例#23
0
 public IActionResult Delete(int contentId, int directoryId)
 {
     videoService.Delete(contentId, User.Identity.Name, DateTime.UtcNow);
     return(RedirectToAction("Index", "Directory", new { id = directoryId }));
 }