Example #1
0
        public IResult AddVideoFile(IFormFile videoFile, int id)
        {
            var result = BusinessRule.Run
                         (
                CheckIfVideoExist(id)
                         );

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

            var selectedVideo = _videoDal.Get(v => v.Id == id);

            selectedVideo.VideoPath = _fileSystem.Add(videoFile, _videoPath);
            selectedVideo.Date      = DateTime.Now;

            _videoDal.Add(selectedVideo);

            return(new SuccessResult());
        }
        public IResult AddProfilePhoto(IFormFile photoFile, int id)
        {
            var selectedPhoto = _userDetailDal.Get(ud => ud.Id == id);

            IResult result = BusinessRule.Run
                             (
                _userService.CheckIfUserExist(selectedPhoto.UserId),
                CheckIfProfilePhotoAlreadyExist(selectedPhoto.Id)
                             );

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

            selectedPhoto.PhotoPath = _fileSystem.Add(photoFile, _path);

            _userDetailDal.Add(selectedPhoto);

            return(new SuccessResult());
        }
        public IResult AddChannelPhoto(IFormFile channelPhotoFile, int id)
        {
            var selectedChannel = _channelDal.Get(c => c.Id == id);

            var result = BusinessRule.Run
                         (
                CheckIfChannelExist(id),
                CheckIfChannelPhotoAlreadyExist(selectedChannel.Id)
                         );

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

            selectedChannel.ChannelPhotoPath = _fileSystem.Add(channelPhotoFile, _path);

            _channelDal.Add(selectedChannel);

            return(new SuccessResult());
        }