public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Pin")] PrivateGroup privateGroup) { if (id != privateGroup.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(privateGroup); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrivateGroupExists(privateGroup.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(privateGroup)); }
public async Task <IActionResult> Create([Bind("Id,Name,Pin")] PrivateGroup privateGroup) { if (ModelState.IsValid) { _context.Add(privateGroup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(privateGroup)); }
public void GetGroupInformation(PrivateGroup privateGroup) { List <MovieWatcher> movieWatchers = _context.MovieWatchers.Where(m => m.MyPrivateGroup == privateGroup).ToList(); List <GenreId> genres = null; foreach (var person in movieWatchers) { genres.Add(person.Questionnaire.Genre); } //if (genres.Count == movieWatchers.Count) //{ // GetMovies(genres); //} }
public async Task <IEnumerable <Room> > GetRooms() { var request = CreateAuthorizedRequest(HttpMethod.Get, new Uri($"{ServerAddress}/api/v1/rooms.get")); var response = await httpClient.SendAsync(request); var responseContent = await response.Content.ReadAsStringAsync(); var responseJson = JsonConvert.DeserializeObject <GetRoomsReponse>(responseContent); var rooms = new List <Room>(); foreach (var room in responseJson.update) { Room newRoom; if (room.t == "c" && room.prid == null) { newRoom = new Channel(room); newRoom.Avatar = avatarsService.GetChannelAvatar(ServerAddress, newRoom.Name); newRoom.AvatarUrl = avatarsService.GetChannelAvatarUrl(ServerAddress, newRoom.Name); } else if (room.t == "c" && room.prid != null) { newRoom = new Discussion(room); newRoom.Avatar = avatarsService.GetChannelAvatar(ServerAddress, newRoom.Name); newRoom.AvatarUrl = avatarsService.GetChannelAvatarUrl(ServerAddress, newRoom.Name); } else if (room.t == "d") { newRoom = new DirectConversation(room); } else { newRoom = new PrivateGroup(room); newRoom.Avatar = avatarsService.GetChannelAvatar(ServerAddress, newRoom.Name); newRoom.AvatarUrl = avatarsService.GetChannelAvatarUrl(ServerAddress, newRoom.Name); } rooms.Add(newRoom); } return(rooms); }
public async Task <IActionResult> MakeGroup(PrivateGroup privateGroup) { if (ModelState.IsValid) { //_context.Add(address); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var movieWatcher = _context.MovieWatchers.Where(m => m.IdentityUserId == userId).First(); Random rand = new Random(); int value = rand.Next(100000, 999999); privateGroup.Pin = value; //_context.PrivateGroups.Add(privateGroup); //_context.SaveChanges(); movieWatcher.MyPrivateGroup = privateGroup; _context.MovieWatchers.Update(movieWatcher); await _context.SaveChangesAsync(); return(RedirectToAction("GetMovies", "PrivateGroups")); } return(View(privateGroup)); }
public void GetHighestRatedMovies(PrivateGroup privategroup) { var privateGroup = _context.PrivateGroups.Where(p => p.Id == privategroup.Id).FirstOrDefault(); List <string> movieChoices = null; List <int> ratingValues = new List <int>(); ratingValues.Add(privateGroup.MovieRanking.MovieRating1); ratingValues.Add(privateGroup.MovieRanking.MovieRating2); ratingValues.Add(privateGroup.MovieRanking.MovieRating3); ratingValues.Add(privateGroup.MovieRanking.MovieRating4); ratingValues.Add(privateGroup.MovieRanking.MovieRating5); int highestAmount = ratingValues.Max(z => z); int secondHighestAmount = ratingValues.OrderByDescending(z => z).Skip(1).First(); if (privateGroup.MovieRanking.MovieRating1 >= secondHighestAmount) { movieChoices.Add("Movie 1"); } if (privateGroup.MovieRanking.MovieRating2 >= secondHighestAmount) { movieChoices.Add("Movie 2"); } if (privateGroup.MovieRanking.MovieRating3 >= secondHighestAmount) { movieChoices.Add("Movie 3"); } if (privateGroup.MovieRanking.MovieRating4 >= secondHighestAmount) { movieChoices.Add("Movie 4"); } if (privateGroup.MovieRanking.MovieRating5 >= secondHighestAmount) { movieChoices.Add("Movie 5"); } VoteOnMovies(movieChoices); }
public IActionResult MakeGroup() { PrivateGroup privateGroup = new PrivateGroup(); return(View(privateGroup)); }