Exemplo n.º 1
0
        public IResult Add(ChannelDto channelDto)
        {
            var userExist = _userService.GetById(channelDto.UserId);

            if (userExist == null)
            {
                return(new ErrorResult("Invalid user"));
            }

            var channel = new Channel
            {
                Name     = channelDto.Name,
                Verified = false,
                UserId   = channelDto.UserId
            };

            if (!_channelDal.Add(channel))
            {
                return(new ErrorResult("Channel cannot created!"));
            }

            channel.Slug = channel.Id.ToString();
            _channelDal.Update(channel);

            return(new SuccessResult("Channel created."));
        }
Exemplo n.º 2
0
 public IDataResult <Channel> Update(Channel channel)
 {
     _validation = new Validation <ChannelValidator>();
     _validation.Validate(channel);
     _channelDal.Update(channel);
     return(new SuccessDataResult <Channel>(Messages.ChannelUpdated, channel));
 }
Exemplo n.º 3
0
        public IResult Update(IFormFile channelPhotoFile, Channel channel)
        {
            IResult result = BusinessRule.Run
                             (
                CheckIfChannelExist(channel.Id)
                             );

            if (result != null)
            {
                return(result);
            }

            var channelToUpdate = _channelDal.Get(cp => cp.Id == channel.Id);

            _fileSystem.Update(channelPhotoFile, channelToUpdate.ChannelPhotoPath, _path);
            channel.InstallationDate = channelToUpdate.InstallationDate;
            channel.UpdateDate       = DateTime.Now;

            _channelDal.Update(channel);

            return(new SuccessResult());
        }