コード例 #1
0
        public async Task <IActionResult> Create(VideoCreateInputModel input)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (user.ChannelId == null)
            {
                return(this.Redirect("/Channels/Create"));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            if (!this.videosService.IsValidTitle(input.Title))
            {
                input.Categories    = this.categoriesService.GetAllCategories <CategoryDropDownViewModel>();
                input.ExistingTitle = "This title already exist!";
                return(this.View(input));
            }

            if (!this.videosService.IsValidUrl(input.Url))
            {
                input.Categories   = this.categoriesService.GetAllCategories <CategoryDropDownViewModel>();
                input.ExsistingUrl = "This url already exist!";
                return(this.View(input));
            }

            var videoId = await this.videosService.CreateVideoAsync(input.Title, input.Url, input.Description, input.CategoryId, user.Id, user.ChannelId);

            return(this.RedirectToAction("Details", new { Id = videoId }));
        }
コード例 #2
0
        public IActionResult Create()
        {
            var viewModel = new VideoCreateInputModel
            {
                Categories = this.categoriesService.GetAllCategories <CategoryDropDownViewModel>(),
            };

            return(this.View(viewModel));
        }
コード例 #3
0
        public async Task <IActionResult> CreateVideo(VideoCreateInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var videoId = await this.videosService.CreateAsync(input.Title, input.Description, input.VideoUrl, input.Category);

            return(this.RedirectToAction("Video", "Video", new { id = videoId, area = string.Empty }));
        }
コード例 #4
0
        public IActionResult CreateVideo()
        {
            var viewModel = new VideoCreateInputModel();

            return(this.View(viewModel));
        }