Beispiel #1
0
        public IActionResult Create()
        {
            var articleCategories = this.articlesCategoriesService.GetAll <ArticlesCategoryDropDowwViewModel>();
            var viewModel         = new CreateVideoInputModel
            {
                ArticlesCategories = articleCategories,
            };

            return(this.View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Create(CreateVideoInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.videosService.CreateAsync(input);

            return(this.RedirectToAction(nameof(this.All)));
        }
 public async Task <IActionResult> Create(int id, CreateVideoInputModel model)
 {
     if (this.User.IsInRole("Administrator"))
     {
         if (!this.ModelState.IsValid)
         {
             return(this.View(model));
         }
         await this.videosService.Create(id, model.VideoUrl);
     }
     return(this.RedirectToAction("AllByArticleId", new { id = id }));
 }
Beispiel #4
0
        public IActionResult Add(CreateVideoInputModel createVideoInputModel)
        {
            if (!ModelState.IsValid)
            {
                this.RedirectToAction(nameof(Add));
            }

            var videoUrl = this.cloudinaryService
                           .UploadVideo(createVideoInputModel.VideoUrl, createVideoInputModel.Name);

            var username = this.User.Identity.Name;

            this.videoService.Add(createVideoInputModel.Name, createVideoInputModel.Category, videoUrl, username);
            var channel = this.channelService.GetChannelByTubeUserName(username);

            return(this.RedirectToAction("Videos", "Channels", new { id = channel.Id }));
        }
Beispiel #5
0
        public async Task <IActionResult> Create(CreateVideoInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                this.ViewData["Error"] = VideoCreateError;
                return(this.View(inputModel));
            }

            var user = await this.userManager.GetUserAsync(this.User);

            var serviceModel = AutoMapperConfig.MapperInstance.Map <VideoServiceModel>(inputModel);

            serviceModel.UserId = user.Id;

            await this.videoService.CreateAsync(serviceModel);

            return(this.RedirectToAction("All", "Video", new { area = string.Empty }));
        }
Beispiel #6
0
        public async Task <int> CreateAsync(CreateVideoInputModel input)
        {
            var    videoInput   = input.VideoUrl;
            string youtubeVideo = MakeYoutubeVideoWorkForMyApp(videoInput);

            var video = new Video
            {
                Title              = input.Title,
                Name               = input.Name,
                Description        = input.Description,
                VideoUrl           = youtubeVideo.ToString().TrimEnd(),
                ArticlesCategoryId = input.ArticlesCategoryId,
            };

            await this.videoRepository.AddAsync(video);

            await this.videoRepository.SaveChangesAsync();

            return(video.Id);
        }