Exemple #1
0
        public IHttpActionResult SetUserMovieRating(HttpRequestMessage httpRequest)
        {
            var userId  = MovieHelper.TryGetIntParameterFromRequest(httpRequest, "user");
            var movieId = MovieHelper.TryGetIntParameterFromRequest(httpRequest, "movie");
            var rating  = MovieHelper.TryGetIntParameterFromRequest(httpRequest, "rating");

            if (userId.HasValue && movieId.HasValue)
            {
                if (rating.HasValue && _validationService.IsRatingValid(rating.Value))
                {
                    if (_validationService.DoesUserExist(userId.Value) && _validationService.DoesMovieExist(movieId.Value))
                    {
                        var userRating = _movieRatingService.SetMovieUserRating(movieId.Value, userId.Value, rating.Value);
                        return(Ok(userRating));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    return(BadRequest("Invalid or missing rating"));
                }
            }
            else
            {
                return(BadRequest("Invalid Id parameter for user or movie"));
            }
        }
        /// <summary>
        /// 通过推荐列表中的movieId找到相关的电影的全部信息
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private static ArrayList getRecommendMovie(IronPython.Runtime.List result)
        {
            ArrayList recommendMovie = new ArrayList();

            for (int i = 0; i < result.Count; i++)
            {
                PythonTuple pySet = result.ElementAt(i) as PythonTuple;

                int movieId = (int)pySet.ElementAt(0);

                RecommendMovie rdMovie = new RecommendMovie();
                rdMovie.Similarity = (double)pySet.ElementAt(1);
                try
                {
                    rdMovie.Movie = MovieHelper.GetMovieById(movieId);
                }
                catch (Exception e)
                {
                    throw (e);
                }

                recommendMovie.Add(rdMovie);
            }

            return(recommendMovie);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var personDB = new PersonDB.Builder().LoadDB(StaticData.PersonsDataPath)
                           .GetAllPersonsFromDB()
                           .Build();

            var movieDB = new MovieDB.Builder().LoadDB(StaticData.MoviesDataPath)
                          .GetAllMoviesFromDB()
                          .Build();

            var ratingDB = new RatingDB.Builder().LoadDB(StaticData.RatingsDataPath)
                           .GetAllRatingsFromDB()
                           .Build();

            var listPerson = personDB.ListPerson;
            var listMovie  = movieDB.ListMovie;
            var listRating = ratingDB.ListRating;

            var movieArrayTwoDimensions = MovieHelper.CreateArrayTwoDimension
                                          (
                rowsLength: listPerson.Count + 1,
                colsLength: listMovie.Count + 1,
                listRating: listRating
                                          );
            var movieSimilarityArray = SimilarityHelper.CalculateSimilarityMatrix(movieArrayTwoDimensions);


            Console.Read();
        }
        private void OnItemSelectedFilter(object sender, EventArgs e)
        {
            var    moviesFiltered = new List <ApiMovie>();
            string selectedItem   = filterByStatusPicker.SelectedItem.ToString();

            var service = DependencyService.Get <Services.IMoviesService>();
            var movies  = service.GetAllMovies();

            if (!selectedItem.Equals("ALL"))
            {
                StatusType status = MovieHelper.GetStatusEnumItem(selectedItem);

                foreach (ApiMovie movie in movies)
                {
                    if (movie.Status.Equals(status))
                    {
                        moviesFiltered.Add(movie);
                    }
                }
                moviesListView.ItemsSource = moviesFiltered;
            }
            else
            {
                moviesListView.ItemsSource = movies;
            }
        }
        public ActionResult SaveMovie(string MovieName, string Category)
        {
            if (!ValidValue(Category) && !ValidValue(MovieName))
            {
                ViewBag.ErrorMessage = "Please complete allfi fields";
                return(View("New"));
            }
            if (!ValidValue(MovieName))
            {
                ViewBag.ErrorMessageName = "Please complete Name field";
                return(View("New"));
            }
            if (!ValidValue(Category))
            {
                ViewBag.ErrorMessageCategory = "Please complete Category field";
                return(View("New"));
            }
            bool moviexsist = MovieHelper.GetMovieList().Exists(x => x.Name == MovieName);

            if (!moviexsist)
            {
                MovieHelper.AddMovie(MovieName, Category);
                ViewBag.ErrorMessage = "The Movie Add To List";
                return(View("New"));
            }
            else
            {
                ViewBag.ErrorMessage = "The Movie already exists";
                return(View("New"));
            }
        }
Exemple #6
0
        public bool AddMovie(MovieHelper movieHelper)
        {
            var db = new DB();

            try
            {
                db.Movie.Add(movieHelper.movie);
                foreach (var category in movieHelper.selectedList)
                {
                    Category          c  = db.Category.Find(int.Parse(category));
                    Category_Relation cr = new Category_Relation
                    {
                        Movie    = movieHelper.movie,
                        Category = c
                    };
                    db.Category_Relations.Add(cr);
                }
                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public ActionResult AddNewRental(string movie, string customerN)
        {
            if (!ValidValue(customerN) && !ValidValue(movie))
            {
                var ErrorMassage = new { ajaxactoin = false, message = "Please enter the name of the Customer and select movie" };
                return(Json(ErrorMassage));
            }
            else if (!ValidValue(customerN))
            {
                var ErrorCustomerMassage = new { ajaxactoin = false, message = "Please enter the name of the Customer" };
                return(Json(ErrorCustomerMassage));
            }
            else if (!ValidValue(movie))
            {
                var ErrorMovieMassage = new { ajaxactoin = false, message = "please select movie" };
                return(Json(ErrorMovieMassage));
            }
            Customer customer      = CustomerHelper.GetCustomers().Where(x => x.Name == customerN).FirstOrDefault();
            Movie    Movie         = MovieHelper.GetMovieList().Where(x => x.Name == movie).FirstOrDefault();
            bool     RentalSuccess = RentalHelper.AddRentals(customer, Movie);

            if (RentalSuccess)
            {
                var RentalIsSuccess = new { ajaxactoin = true, message = "The rent was made" };
                return(Json(RentalIsSuccess));
            }
            else
            {
                var Rentalfailed = new { ajaxactoin = false, message = "The rent failed" };
                return(Json(Rentalfailed));
            }
        }
Exemple #8
0
        private void AddToMyList(object sender, EventArgs e)
        {
            Button      button       = (Button)sender;
            StackLayout listViewItem = (StackLayout)button.Parent;
            Label       label        = (Label)listViewItem.Children[0];

            String movieId   = MovieHelper.GetId(label.Text);
            String movieName = MovieHelper.GetName(label.Text);

            var            service = DependencyService.Get <Services.IMoviesService>();
            ResponseStatus reponse = service.AddMovieToMyList(movieName, Model.StatusType.NOT_STARTED, int.Parse(movieId));

            if (ResponseStatus.OK.Equals(reponse))
            {
                DisplayAlert("Success", "Movie added!", "Ok");
            }
            else if (ResponseStatus.NOT_OK.Equals(reponse))
            {
                DisplayAlert("Failure", "Movie not added!", "Ok");
            }
            else
            {
                DisplayAlert("Failure", "Movie is already in your list!", "Ok");
            }
        }
Exemple #9
0
        private async Task <bool> GenerateMovieLastWeek(ulong guildId, SocketTextChannel channel)
        {
            string fileName = await MovieHelper.GenerateMovieForMessages(guildId, 24 * 7, 30, -1, 10, true, true, "");

            await channel.SendFileAsync(fileName, "Message graph for last week");

            return(true);
        }
 public MovieController(MovieHelper movieHelper)
 {
     // Initialize spinner
     MovieDbFactory.RegisterSettings(new MovieDbSettings());
     this._movieHelper = movieHelper;
     this.TabBarItem   = new UITabBarItem(UITabBarSystemItem.Search, 0);
     activitySpinner   = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
 }
 public TopRatedMovieController(MovieHelper movieHelper)
 {
     this._reload = true;
     MovieDbFactory.RegisterSettings(new MovieDbSettings());
     this._movieHelper = movieHelper;
     _topMoviesList    = new List <Movie>();
     this.TabBarItem   = new UITabBarItem(UITabBarSystemItem.Favorites, 0);
     activitySpinner   = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
 }
Exemple #12
0
        public async Task <ActionResult <MovieViewModel> > API_B([FromQuery] int numberToRetrieve = 5)
        {
            List <Movie> movies = await _movieCollectionService.GetTopRatedMovies(numberToRetrieve);

            if (movies.Count > 0)
            {
                return(Ok(MovieHelper.GetMovieViewModels(movies)));
            }

            return(NotFound());
        }
Exemple #13
0
        public static MoviesIndexViewModel GetAllByCategory(DatabaseContext db, string category)
        {
            var viewModel = new MoviesIndexViewModel
            {
                Movies = MovieHelper.GetMovies(db.Movies, category),
                AvailableCategories = MovieHelper.GetCategories(db.Movies).ToList(),
                SelectedCategory    = category
            };

            return(viewModel);
        }
            public Builder GetAllMoviesFromDB()
            {
                foreach (var data in this.datas)
                {
                    if (!string.IsNullOrEmpty(data))
                    {
                        ListMovie.Add(MovieHelper.GetDataMovieFromString(data));
                    }
                }

                return(this);
            }
Exemple #15
0
        public void TestMethod_Search()
        {
            // Arrange
            MovieHelper movieHelper = new MovieHelper();

            // Act
            var contentResult = movieHelper.Search(mockMovieList, "Dredd");

            // Assert
            Assert.AreEqual(contentResult.Count, 1);
            Assert.AreEqual(contentResult[0].Title, "Dredd");
        }
        public void openMovieFromCarousel(string movieName)
        {
            MoviesDetailPage moviesDetailPage = new MoviesDetailPage(WebDriver);
            NavBarPage       navBarPage       = new NavBarPage(WebDriver);

            navBarPage.lnkHome.Click();
            MovieHelper.ReadMovies(lnkMovies, WebDriver);
            var index = MovieHelper.findMovieIndex(movieName);

            lnkMovies.ElementAt(index).Click();
            moviesDetailPage.addtoCart();
            Thread.Sleep(1000);
        }
Exemple #17
0
        public async Task SocialCreditGraph()
        {
            var author = Context.Message.Author;

            if (author.Id != Program.ApplicationSetting.Owner)
            {
                await Context.Channel.SendMessageAsync("You aren't allowed to run this command", false);

                return;
            }

            List <SocialCreditUser> users = new List <SocialCreditUser>();

            using (var connection = new SqliteConnection("Data Source=C:\\AprilFoolsBot\\test.db"))
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandText =
                    @"SELECT * FROM DiscordUsers";
                //command.Parameters.AddWithValue("$id", id);

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var id   = Convert.ToUInt64(reader.GetString(0));
                        var name = reader.GetString(1);
                        users.Add(new SocialCreditUser()
                        {
                            Id           = id, Name = name,
                            Transactions = new List <SocialCreditTransaction>()
                            {
                            }
                        });
                    }
                }
            }

            try
            {
                string fileName = await MovieHelper.GenerateMovieForMessages(Context.Guild.Id, 24 * 7, 30, -1, 15, true, true);

                await Context.Channel.SendFileAsync(fileName);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while creating movie");
                await Context.Channel.SendMessageAsync(ex.ToString());
            }
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            if (Session["Admin"] == null)
            {
                return(View("NotAllowed"));
            }
            var         movieBLL = new MovieBLL();
            MovieHelper mh       = new MovieHelper()
            {
                selectList = movieBLL.GetCategories()
            };

            return(View(mh));
        }
        // Legg til ny Film
        public ActionResult AddMovie()
        {
            MovieBLL    movieBLL    = new MovieBLL();
            MovieHelper movieHelper = new MovieHelper
            {
                selectList = movieBLL.GetCategories()
            };

            if (Session["Admin"] == null)
            {
                return(View("NotAllowed"));
            }
            return(View(movieHelper));
        }
        public ActionResult AddMovie(MovieHelper movieHelper)
        {
            var  movieBLL   = new MovieBLL();
            bool movieAdded = movieBLL.AddMovie(movieHelper);

            if (movieAdded)
            {
                ViewBag.RegistrationSuccess = "Movie added";
                return(RedirectToAction("../Home/Index"));
            }
            ViewBag.RegistrationFailed = "Movie Failed";
            movieHelper.selectList     = movieBLL.GetCategories();
            return(View(movieHelper));
        }
Exemple #21
0
        public async Task <ActionResult <MovieViewModel> > GetMovie(int id)
        {
            var movie = await _dbContext.Movies.Where(x => x.Id == id)
                        .Include(x => x.MovieGenreAssignments).ThenInclude(x => x.Genre)
                        .Include(x => x.UserReviews)
                        .FirstOrDefaultAsync();

            if (movie != null)
            {
                return(Ok(MovieHelper.GetMovieViewModel(movie)));
            }

            return(NotFound());
        }
Exemple #22
0
        public void openMovieFromList(string movieName)
        {
            MoviesDetailPage moviesDetailPage = new MoviesDetailPage(WebDriver);

            MovieHelper.ReadMovies(lnkMovies, WebDriver);
            var index = MovieHelper.findMovieIndex(movieName);

            lnkMovies.ElementAt(index).Click();
            //txtSearchBar.SendKeys(movieName);
            //movieLink.Click();
            moviesDetailPage.addtoCart();
            //txtSearchBar.Clear();
            Thread.Sleep(1000);
        }
Exemple #23
0
        public static ShoppingCartIndexViewModel GetAllByCategory(DatabaseContext db, string category)
        {
            var mainShoppingCart = db.ShoppingCarts.First();
            var movies           = mainShoppingCart.Movies.AsQueryable();

            var viewModel = new ShoppingCartIndexViewModel
            {
                Movies = MovieHelper.GetMovies(movies, category),
                AvailableCategories = MovieHelper.GetCategories(movies).ToList(),
                SelectedCategory    = category
            };

            return(viewModel);
        }
        public ActionResult EditMovie(int id, MovieHelper movieHelper)
        {
            var movieBLL = new MovieBLL();

            if (movieBLL.EditMovie(id, movieHelper))
            {
                ViewBag.EditSuccessfull = "Endret film";
                return(RedirectToAction("AllMovies"));
            }

            movieHelper.selectedList = movieBLL.SelectedCategoriesIDs(id);
            movieHelper.selectList   = movieBLL.GetCategories();
            ViewBag.EditSuccessfull  = "Endring feilet";
            return(View(movieHelper));
        }
Exemple #25
0
        public async Task <ActionResult <MovieViewModel> > API_A([FromQuery] MovieFilter filter)
        {
            if (!MovieHelper.IsValidMovieFilter(filter))
            {
                return(BadRequest());
            }

            List <Movie> movies = await _movieCollectionService.GetMoviesByFilter(filter);

            if (movies.Count > 0)
            {
                return(Ok(MovieHelper.GetMovieViewModels(movies)));
            }

            return(NotFound());
        }
Exemple #26
0
        public async Task <ActionResult <MovieViewModel> > API_C([FromQuery] int userID = 0, int numberToRetrieve = 5)
        {
            if (userID == 0)
            {
                return(BadRequest());
            }

            List <Movie> movies = await _movieCollectionService.GetTopRatedMoviesByUser(userID, numberToRetrieve);

            if (movies.Count > 0)
            {
                return(Ok(MovieHelper.GetMovieViewModels(movies)));
            }

            return(NotFound());
        }
Exemple #27
0
        public void TestMethod_Helper_Sort()
        {
            // Arrange
            MovieHelper movieHelper = new MovieHelper();

            // Act
            //order by title
            var result1 = movieHelper.OrderMovies(mockMovieList, "Title");
            var result2 = movieHelper.OrderMovies(mockMovieList, "Classification");
            var result3 = movieHelper.OrderMovies(mockMovieList, "Genre");

            // Assert
            Assert.AreEqual("Dredd", result1[0].Title);
            Assert.AreEqual("A", result2[0].Classification);
            Assert.AreEqual("G1", result3[0].Genre);
        }
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            MovieDbFactory.RegisterSettings(new MovieDbSettings());
            _topRatedHelper = new MovieHelper();
            _searchHelper   = new MovieHelper();
            _movieApi       = MovieDbFactory.Create <IApiMovieRequest>().Value;

            _topRatedFragment = new TopRatedMoviesFragment(_topRatedHelper, _movieApi);

            var fragments = new Fragment[]
            {
                new MovieSearchFragment(_searchHelper, _movieApi),
                _topRatedFragment
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                activity.GetString(Resource.String.SearchTab),
                activity.GetString(Resource.String.TopRatedTab)
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);

            tabLayout.TabSelected += async(sender, args) =>
            {
                var tab = args.Tab;
                if (tab.Position == 1)
                {
                    viewPager.SetCurrentItem(tab.Position, true);
                    var manager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
                    manager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, 0);
                    await _topRatedFragment.GetMovies();
                }
                else
                {
                    viewPager.SetCurrentItem(tab.Position, true);
                }
            };

            SetToolbar(activity, toolbar);
        }
Exemple #29
0
        public async Task RecommendBookFromDb(string title)
        {
            var regexedTitle = string.Empty;

            if (IsItASeries(title))
            {
                regexedTitle = SeriesHelper.GetTitle(title);
            }
            else
            {
                regexedTitle = MovieHelper.GetTitle(title);
            }

            //var books = await new WebClientManager().RecommendBooksByString(_endpoint + "/book/get/recommendations/" + regexedTitle);

            //MessageBox.Show("Recommended book by this:"+books[0].Title);
        }
        // Rediger Film
        public ActionResult EditMovie(int id)
        {
            var   movieBLL = new MovieBLL();
            Movie movie    = movieBLL.GetMovie(id);

            if (movie == null)
            {
                return(RedirectToAction("AllMovies"));               // Movie not found
            }
            MovieHelper movieHelper = new MovieHelper
            {
                movie        = movie,
                selectList   = movieBLL.GetCategories(),
                selectedList = movieBLL.SelectedCategoriesIDs(id)
            };

            return(View(movieHelper));
        }