public Video Create(CreateVideoCommand command)
        {
            var video = new Video(command.Url, command.TvAdditional, command.IdTypeVideo, command.IdTimeVideo, command.IdCompany, command.IdCategoryVideo, command.IdPlan, command.DateEnd, command.DateStart, command.ListVideoEquipment);

            //Marca todos itens da lista ListVideoEquipment com status Ativo
            foreach (var videoEquipment in command.ListVideoEquipment)
            {
                videoEquipment.Status       = EStatusVideoEquipment.Ativo;
                videoEquipment.DateRegister = DateTime.Now;
            }

            video.Create();
            _repository.Create(video);

            Commit();

            foreach (var videoEquipment in command.ListVideoEquipment)
            {
                var     item      = _repositoryVideoEquipment.GetById(videoEquipment.IdVideoEquipment);
                decimal valueByTv = _repositoryBalance.GetValueByVideo(item.IdVideo);
                var     history   = new HistoryEquipment(item.IdVideo, item.IdEquipment, item.ControlLoan.IdCompany, item.Video.Plan.Description, EAction.Inclusão, valueByTv);
                history.Create();
                _repositoryHistoryEquipment.Create(history);
            }



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

            return(null);
        }
        public void UpdateStatusListVideo()
        {
            VideoEquipment videoEquipment     = new VideoEquipment();
            var            listVideoEquipment = _repository.GetByStatus(EStatusVideoEquipment.Ativo);
            ICollection <VideoEquipment> listVideoEquipmentUpdate = videoEquipment.UpdateStatusListVideo(listVideoEquipment);

            foreach (var video in listVideoEquipmentUpdate)
            {
                var     item      = _repositoryVideoEquipment.GetById(videoEquipment.IdVideoEquipment);
                decimal valueByTv = _repositoryBalance.GetValueByVideo(item.IdVideo);
                var     history   = new HistoryEquipment(item.IdVideo, item.IdEquipment, item.ControlLoan.IdCompany, item.Video.Plan.Description, EAction.Exclusão, valueByTv);
                history.Create();
                _repositoryHistoryEquipment.Create(history);
            }

            _repository.UpdateStatusListVideo(listVideoEquipmentUpdate);

            Commit();
        }
 public VideoEquipment GetById(int id)
 {
     return(_repository.GetById(id));
 }