예제 #1
0
        public async Task <IActionResult> Edit(int id, EditVideoInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                input.ArticlesCategories = this.articlesCategoriesService.GetAll <ArticlesCategoryDropDowwViewModel>();
                return(this.View(input));
            }

            await this.videosService.UpdateAsync(id, input);

            return(this.RedirectToAction(nameof(this.ById), new { id }));
        }
예제 #2
0
        public async Task UpdateAsync(int id, EditVideoInputModel input)
        {
            var    videoInput   = input.VideoUrl;
            string youtubeVideo = MakeYoutubeVideoWorkForMyApp(videoInput);

            var video = this.videoRepository.All().FirstOrDefault(x => x.Id == id);

            video.Title              = input.Title;
            video.Name               = input.Name;
            video.Description        = input.Description;
            video.VideoUrl           = youtubeVideo;
            video.ArticlesCategoryId = input.ArticlesCategoryId;
            await this.videoRepository.SaveChangesAsync();
        }