Ejemplo n.º 1
0
 public ActionResult Delete(int id)
 {
     try
     {
         var obj = _videoRepository.Find(id);
         _videoRepository.Delete(id);
         if (obj.Type == 1)
         {
             var file = Server.MapPath(obj.Url);
             if (System.IO.File.Exists(file))
             {
                 Common.TryToDelete(file);
             }
         }
     }
     catch (Exception)
     {
         return(Json(new
         {
             IsSuccess = false,
             Messenger = string.Format("Xóa Video thất bại")
         }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new
     {
         IsSuccess = true,
         Messenger = "Xóa Video thành công",
     }, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(int VideoId)
        {
            try
            {
                var delete = repository.GetVideosById(VideoId);
                if (delete == null)
                {
                    return(NotFound("Video not found"));
                }

                repository.Delete(VideoId);

                if (await repository.SaveChangesAsync())
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("Failed to delete record"));
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }
        }
Ejemplo n.º 3
0
        public ICommandResult Handle(DeleteVideoCommand command)
        {
            command.Validate();
            if (command.IsInvalid)
            {
                return(new DefaultCommandResult(CommandResultStatus.InvalidCommand, command.Notifications));
            }

            try
            {
                var video = _videoRepository.GetByServerIdAndVideoId(command.ServerId, command.VideoId);
                if (video == null)
                {
                    return(new DefaultCommandResult(CommandResultStatus.InvalidData, "Video não foi localizado"));
                }

                _videoRepository.Delete(video);
                _videoRepository.DeleteInFileSystem(video);
                return(new DefaultCommandResult(CommandResultStatus.Success, "Video excluido com sucesso", null));
            }
            catch (Exception e)
            {
                Console.WriteLine($"Fail to execute DeleteVideoHandler. Fail stack ===> {e.ToString()}");
                return(new DefaultCommandResult(CommandResultStatus.Exception));
            }
        }
Ejemplo n.º 4
0
        public ICommandResult Execute(DeleteVideoCommand command)
        {
            var Video = VideoRepository.GetById(command.Id);

            VideoRepository.Delete(Video);
            unitOfWork.Commit();
            return(new CommandResult(true));
        }
Ejemplo n.º 5
0
 public void Delete(long videoId)
 {
     try
     {
         db.Delete(videoId);
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message, ex);
     }
 }
Ejemplo n.º 6
0
        void DeleteMenu()
        {
            Console.WriteLine("Delete video");
            ListVideos();
            Console.Write("Select a video: ");
            Video selected = VideoRepository.ReadById(ToNumber());

            VideoRepository.Delete(selected.Id);
            Console.WriteLine("Video deleted SUCCESSFULLY!");
            exit = Console.ReadLine();
        }
        public void Delete(string fileLocation)
        {
            // Remove trailing forward slash if there is one
            if (fileLocation.EndsWith('/'))
            {
                fileLocation = fileLocation.Remove(fileLocation.Length - 1);
            }
            var fileName = fileLocation.Split('/').Last();

            _videoRepo.Delete(fileName);
        }
Ejemplo n.º 8
0
        public ICommandResult Handle(RecycleVideoForMoreThenDaysCommand command)
        {
            command.Validate();
            if (command.IsInvalid)
            {
                return(new DefaultCommandResult(CommandResultStatus.InvalidCommand, command.Notifications));
            }

            try
            {
                var statusRecycle = _recycleRepository.Get();
                if (statusRecycle == null)
                {
                    statusRecycle = new Entities.Recycle(RecyclerStatus.NotRunning, new DateTime());
                    _recycleRepository.Save(statusRecycle);
                }
                var deleteBeforeDate = DateTime.Now.Subtract(TimeSpan.FromDays(command.Days));
                var videos           = _videoRepository.GetAllBeforeDate(deleteBeforeDate);
                if (videos.Count() > 0)
                {
                    statusRecycle.SetRunning(deleteBeforeDate);
                    _recycleRepository.Update(statusRecycle);

                    try
                    {
                        Thread.Sleep(5000);

                        foreach (var video in videos)
                        {
                            _videoRepository.DeleteInFileSystem(video);
                            _videoRepository.Delete(video);
                        }
                        statusRecycle.StopRunning();
                        _recycleRepository.Update(statusRecycle);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Fail to execute RecycleVideoForMoreThenDaysHandler. Fail stack ===> {e.ToString()}");
                        statusRecycle.StopRunning();
                        _recycleRepository.Update(statusRecycle);
                    }
                }


                return(new DefaultCommandResult());
            }
            catch (Exception e)
            {
                Console.WriteLine($"Fail to execute RecycleVideoForMoreThenDaysHandler. Fail stack ===> {e.ToString()}");
                return(new DefaultCommandResult(CommandResultStatus.Exception));
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Delete(string name)
        {
            var videoFromDb = await _videoRepository.GetVideo(name);

            if (videoFromDb == null)
            {
                return(new NotFoundResult());
            }

            await _videoRepository.Delete(name);

            return(new OkResult());
        }
Ejemplo n.º 10
0
        public IHttpActionResult DeleteVideo(int id)
        {
            Video video = repo.GetByID(id);

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

            repo.Delete(id);
            repo.Save();

            return(Ok(video));
        }
Ejemplo n.º 11
0
        public async Task <ActionResultResponse> Delete(string tenantId, string videoId)
        {
            var info = await _videoRepository.GetInfo(videoId);

            if (info == null)
            {
                return(new ActionResultResponse(-1, _websiteResourceService.GetString("Video does not exists. Please try again.")));
            }

            if (info.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            var result = await _videoRepository.Delete(videoId);

            await _videoTranslationRepository.Delete(videoId);

            return(new ActionResultResponse(result, _websiteResourceService.GetString("Delete video successful.")));
        }
Ejemplo n.º 12
0
 public DataModel.Response.BaseResponse DeleteVideo(string id)
 {
     try
     {
         IVideoRepository videoRepository = RepositoryClassFactory.GetInstance().GetVideoRepository();
         videoRepository.Delete(id);
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.None,
             Message = Resources.Resource.msg_delete_success
         });
     }
     catch (Exception ex)
     {
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }
        public Video Delete(DeleteVideoCommand command)
        {
            var video = _repository.GetById(command.IdVideo);

            video.Delete();
            _repository.Delete(video);

            //Caso o vídeo seja inativado ele também será inativado na tabela VideoEquipment
            var            listVideoEquipment          = _repositoryVideoEquipment.GetAllByVideo(command.IdVideo);
            VideoEquipment videoEquipment              = new VideoEquipment();
            var            listVideoEquipmentInativada = videoEquipment.Delete(listVideoEquipment);

            _repositoryVideoEquipment.Delete(listVideoEquipmentInativada);

            if (Commit())
            {
                return(video);
            }

            return(null);
        }
        public JsonResult DeleteConfirmed(int id, string confirmText)
        {
            var        success = false;
            var        error   = "";
            List <int> ids     = new List <int>();

            if (confirmText.ToLower() == "đồng ý")
            {
                var scheduleDetail = _scheduleDetailRepository.Find(id);
                if (scheduleDetail != null)
                {
                    if (scheduleDetail.VideoId.HasValue && scheduleDetail.IsNew == true)
                    {
                        var videoId = scheduleDetail.VideoId.Value;
                        var video   = _videoRepository.Find(videoId);
                        //Xóa toàn bộ các chương trình liên quan
                        for (int i = video.ScheduleDetails.Count - 1; i >= 0; i--)
                        {
                            var scheduleDetailId = video.ScheduleDetails.ElementAt(i).Id;
                            ids.Add(scheduleDetailId);
                            _scheduleDetailRepository.Delete(scheduleDetailId);
                        }
                        _scheduleDetailRepository.Save();

                        //Xóa video
                        using (new Impersonator("uploaduser", "", "Upload@@123"))
                        {
                            string thumbnailPath = VITV.Web.Helpers.UrlHelper.GetPhysicalPath(this, video.Thumbnail);
                            if (System.IO.File.Exists(thumbnailPath))
                            {
                                System.IO.File.Delete(thumbnailPath);
                            }

                            string videoPath = VITV.Web.Helpers.UrlHelper.GetPhysicalPath(this, video.Url);

                            if (System.IO.File.Exists(videoPath))
                            {
                                System.IO.File.Delete(videoPath);
                            }
                        }
                        _videoRepository.Delete(videoId, User.Identity.Name, "Xóa lịch phát sóng");
                        _videoRepository.Save();
                    }

                    else
                    {
                        ids.Add(id);
                        //Xóa chương trình
                        _scheduleDetailRepository.Delete(id);
                        _scheduleDetailRepository.Save();
                    }
                    success = true;
                }
                else
                {
                    error = "Không tìm thấy chương trình";
                }
            }
            else
            {
                error = "Chuỗi nhập vào không đúng";
            }
            return(Json(new { success = success, ids = ids, error = error }));
        }
Ejemplo n.º 15
0
 public void Delete(Video Video)
 {
     VideoRepository.Delete(Video);
 }
Ejemplo n.º 16
0
 public void Delete(Video Entity)
 {
     _videoRepository.Delete(Entity);
 }
Ejemplo n.º 17
0
 public async Task Delete(Video entity)
 {
     await _videoRepository.Delete(entity);
 }
Ejemplo n.º 18
0
        public ActionResult VideoTests()
        {
            try
            {
                var ctm = new CacheTestModel();

                var c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (c == null)
                {
                    ctm.Message = "Initial Get Failed";
                    return(View(ctm));
                }

                var dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                var s = new Video();
                s.GHLocationID = 1;
                s.Description  = "Location Controller Test";
                s.Url          = "test";
                s.UserName     = UserHelper.Instance.CurrentUserName;
                _vr.Insert(s);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Insert Failed";
                    return(View(ctm));
                }
                dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                s.Description = "Cache Update Test";
                _vr.Update(s);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Update Failed";
                    return(View(ctm));
                }
                dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                _vr.Delete(s);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Delete Failed";
                    return(View(ctm));
                }

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                ctm.Message = "Success";

                return(View(ctm));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(new HttpStatusCodeResult(500));
            }
        }
Ejemplo n.º 19
0
 public Video Delete(int id)
 {
     return(_videoRepository.Delete(id));
 }
Ejemplo n.º 20
0
 /// <summary>
 ///     删除视频
 /// </summary>
 /// <param name="id"></param>
 public void DeleteVideo(int id)
 {
     _videoRepository.Delete(id);
 }