public Response DeleteChannel(Guid idChannel)
        {
            bool existe = _repositoryVideo.ThereIsAssociatedChannel(idChannel);

            if (existe)
            {
                AddNotification("Canal", MSG.NAO_E_POSSIVEL_EXCLUIR_UM_X0_ASSOCIADO_A_UM_X1.ToFormat("canal", "vídeo"));
                return(null);
            }

            Channel channel = _repositoryChanner.Get(idChannel);

            if (channel == null)
            {
                AddNotification("Canal", MSG.DADOS_NAO_ENCONTRADOS);
            }

            if (IsInvalid())
            {
                return(null);
            }

            _repositoryChanner.Delete(channel);

            return(new Response()
            {
                Message = MSG.OPERACAO_REALIZADA_COM_SUCESSO
            });
        }
Example #2
0
        public AddVideoResponse AddVideo(AddVideoRequest request, Guid idUser)
        {
            if (request == null)
            {
                AddNotification("AdicionarVideoRequest", MSG.OBJETO_X0_E_OBRIGATORIO.ToFormat("AdicionarVideoRequest"));
                return(null);
            }

            User user = _repositoryUser.Get(idUser);

            if (user == null)
            {
                AddNotification("User", MSG.X0_NAO_INFORMADO.ToFormat("Usuário"));
                return(null);
            }

            Channel channel = _repositoryChannel.Get(request.IdChannel);

            if (channel == null)
            {
                AddNotification("Canal", MSG.X0_NAO_INFORMADO.ToFormat("Canal"));
                return(null);
            }

            PlayList playList = null;

            if (request.IdPlayList != Guid.Empty)
            {
                playList = _repositoryPlayList.Get(request.IdPlayList);
                if (playList == null)
                {
                    AddNotification("PlayList", MSG.X0_NAO_INFORMADA.ToFormat("playList"));
                    return(null);
                }
            }

            var video = new Video(channel, playList, request.Title, request.Description, request.Tags, request.OrderPlayList, request.IdVideoYoutube, user);

            AddNotifications(video);

            if (this.IsInvalid())
            {
                return(null);
            }

            _repositoryVideo.Add(video);

            return(new AddVideoResponse(video.Id));
        }