예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("WatchPartyId,Title,Description,Address,Limit,Date,UserId,ImagePath,TeamId")] WatchParty watchParty)
        {
            if (id != watchParty.WatchPartyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(watchParty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WatchPartyExists(watchParty.WatchPartyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", watchParty.UserId);
            return(View(watchParty));
        }
        public async Task <IHttpActionResult> PutWatchParty(int id, WatchParty watchParty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != watchParty.PartyID)
            {
                return(BadRequest());
            }

            db.Entry(watchParty).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WatchPartyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetWatchParty(int id)
        {
            WatchParty watchParty = await db.WatchParties.FindAsync(id);

            if (watchParty == null)
            {
                return(NotFound());
            }

            return(Ok(watchParty));
        }
        public async Task <IHttpActionResult> PostWatchParty(WatchParty watchParty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.WatchParties.Add(watchParty);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = watchParty.PartyID }, watchParty));
        }
        public async Task <IHttpActionResult> DeleteWatchParty(int id)
        {
            WatchParty watchParty = await db.WatchParties.FindAsync(id);

            if (watchParty == null)
            {
                return(NotFound());
            }

            db.WatchParties.Remove(watchParty);
            await db.SaveChangesAsync();

            return(Ok(watchParty));
        }
예제 #6
0
        public IActionResult ToggleParty(int movieId, string status)
        {
            User current = GetUser();

            if (current == null)
            {
                return(Redirect("/"));
            }
            if (status == "join")
            {
                WatchParty newParty = new WatchParty();
                newParty.UserId  = current.UserId;
                newParty.MovieId = movieId;
                _context.Parties.Add(newParty);
            }
            else if (status == "leave")
            {
                WatchParty backout = _context.Parties.FirstOrDefault(w => w.UserId == current.UserId && w.MovieId == movieId);
                _context.Parties.Remove(backout);
            }
            _context.SaveChanges();
            return(RedirectToAction("Home"));
        }
예제 #7
0
        public async Task <IActionResult> EditWatchParty(int id, [Bind("WatchPartyId,Title,Description,Address,Limit,Date,UserId,ImagePath,TeamId")] WatchParty watchParty)
        {
            if (id != watchParty.WatchPartyId)
            {
                return(NotFound());
            }
            ModelState.Remove("UserId");

            var currentuser = await GetCurrentUserAsync();

            if (ModelState.IsValid)
            {
                watchParty.UserId = currentuser.Id;

                _context.Update(watchParty);
                await _context.SaveChangesAsync();


                return(RedirectToAction(nameof(Index)));
            }

            return(View(watchParty));
        }
예제 #8
0
        private void StartWatchParty()
        {
            _console.Clear();
            _console.WriteLine("Enter your name");
            string yourName = _console.ReadLine();

            _console.WriteLine("Enter other friends");
            string     friendsNames = _console.ReadLine();
            WatchParty newParty     = new WatchParty(yourName, friendsNames);

            _console.WriteLine($"You({newParty.YourName}) and your friends({newParty.FriendsNames}) are now in a party");
            _console.WriteLine("What movie would you like to watch?");
            string           title   = _console.ReadLine();
            StreamingContent content = _repo.GetContentByTitle(title);

            if (content == null)
            {
                _console.WriteLine("no content found");
            }
            else
            {
                _console.WriteLine("Your party is now watching " + content.Title);
            }
        }