Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ProjectVideosId,SavedProjectId,VideoId,XPositition,YPosition")] ProjectVideos projectVideos)
        {
            if (id != projectVideos.ProjectVideosId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(projectVideos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectVideosExists(projectVideos.ProjectVideosId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["VideoId"] = new SelectList(_context.Set <Video>(), "VideoId", "UserId", projectVideos.VideoId);
            return(View(projectVideos));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ProjectVideosId,SavedProjectId,VideoId,XPositition,YPosition")] ProjectVideos projectVideos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(projectVideos);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["VideoId"] = new SelectList(_context.Set <Video>(), "VideoId", "UserId", projectVideos.VideoId);
            return(View(projectVideos));
        }
        public async Task <IActionResult> AddOverLayVideoToDB(int id)
        {
            var user = await GetCurrentUserAsync();

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            var video = await _context.Video.SingleOrDefaultAsync(v => v.VideoId == id);

            var currentProject = await _context.Project
                                 .SingleOrDefaultAsync(m => m.User == user && m.Title == null);

            if (currentProject == null)
            {
                ModelState.Remove("Project.Title");
                Project project = new Project()
                {
                    User = user
                };
                _context.Project.Add(project);
                ProjectVideos projectVideos = new ProjectVideos()
                {
                    VideoId = video.VideoId, ProjectId = project.ProjectId, User = user, BackGround = false
                };
                _context.ProjectVideos.Add(projectVideos);
                await _context.SaveChangesAsync();

                return(RedirectToAction("NewProjectDisplay", "Projects"));
            }
            else
            {
                ProjectVideos pv = new ProjectVideos()
                {
                    VideoId = video.VideoId, ProjectId = currentProject.ProjectId, User = user, BackGround = false
                };
                _context.ProjectVideos.Add(pv);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("NewProjectDisplay", "Projects"));
        }