Exemple #1
0
        public async Task <IActionResult> AddVideo(AddVideoToLectureInputModel input, int id)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

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

            this.TempData["Message"] = "Video added successfully to the Lecture!";
            input.LectureId          = id;
            input.UserId             = user.Id;
            await this.lecturesService.AddVideoAsync(input);

            return(this.Redirect("/"));
        }
Exemple #2
0
        public async Task AddVideoAsync(AddVideoToLectureInputModel input)
        {
            Lecture lecture = this.lecturesRepository.All().FirstOrDefault(l => l.Id == input.LectureId);

            File file = new File
            {
                Extension = ".mp4",
                RemoteUrl = input.RemoteUrl,
                LectureId = input.LectureId,
                UserId    = input.UserId,
            };

            await this.filesRepository.AddAsync(file);

            await this.lecturesRepository.SaveChangesAsync();

            await this.filesRepository.SaveChangesAsync();
        }