public List <UserModel> TakeMoviesToUsers(int loggedUser, MovieModel model, int ocena) { bool flag = true; List <UserModel> users = GetAllUsers(); List <UserModel> usersSave = new List <UserModel>(); if (model != null) { flag = TextConnectorProcessor.ValidateRating(users, model, loggedUser); foreach (UserModel user in users) { if (flag && loggedUser == user.Id) { user.WatchedMovie.Add(model); user.ocena = ocena; usersSave.Add(AddGenrePoints(model, user, ocena)); } if (flag && loggedUser != user.Id) { usersSave.Add(user); } if (!flag) { return(users); } } } return(usersSave); }
public List <MovieModel> RatingMovie(MovieModel model, int ocena, List <MovieModel> list, int loggedUser) { bool flag = true; List <MovieModel> afterGrading = new List <MovieModel>(); UserModel user = new UserModel(); List <UserModel> users = GetAllUsers(); flag = TextConnectorProcessor.ValidateRating(users, model, loggedUser); if (model != null && flag == true) { model.Counter += 1; model.Total += ocena; model.MovieRating = (model.Total) / (model.Counter); model.MovieRating = Math.Round(model.MovieRating, 2); foreach (MovieModel p in list) { if (p.Id == model.Id) { p.Counter = model.Counter; p.Total = model.Total; p.MovieRating = model.MovieRating; } afterGrading.Add(p); } return(afterGrading); } return(list); }