Exemplo n.º 1
0
        public async Task <IActionResult> AddFile(string name, string disc, string genre, IFormFile photo, string trailer, string filmLink)
        {
            Random r    = new Random();
            var    link = r.Next(-99999, 99999).ToString() + name;

            if (name != null)
            {
                string fileName = r.Next(0, 9999999).ToString() + photo.FileName;
                string Path     = @"\img\" + fileName;
                using (var fs = new FileStream(_appEnviroment.WebRootPath + Path, FileMode.Create))
                {
                    await photo.CopyToAsync(fs);
                }
                using (MyDbContext db = new MyDbContext())
                {
                    Film film = new Film()
                    {
                        Name = name, Disc = disc, Img = fileName, Genre = genre, Link = link
                    };
                    FilmPage fm = new FilmPage()
                    {
                        Name = name, Discription = disc, Img = fileName, FilmLink = filmLink, TrailerLink = trailer, Link = link, Genre = genre, FilmViews = 1, InFavList = 1
                    };
                    db.Films.Add(film);
                    db.FilmPages.Add(fm);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public static Frame CallFilm(object sender, MouseEventArgs e, ListBox l, List <String> lastUrl)
        {
            Film     f        = (Film)l.SelectedItem;
            FilmPage filmPage = new FilmPage(f.url, lastUrl);
            TabItem  tabItem  = new TabItem();
            Frame    tabFrame = new Frame();

            tabFrame.Content = filmPage;
            return(tabFrame);
        }
Exemplo n.º 3
0
 public IActionResult Index(string f)
 {
     using (var db = new MyDbContext())
     {
         List <FilmPage> Pages = db.FilmPages.ToList <FilmPage>();
         //Find db FilmPage film which link is filmlink
         FilmPage film = Pages.FirstOrDefault(a => a.Link == f);
         film.FilmViews += 1;
         db.FilmPages.Update(film);
         db.SaveChanges();
         ViewData["Film"] = film;
     }
     return(View());
 }
Exemplo n.º 4
0
        public static Frame GoBack(List <String> backUrl)
        {
            Frame  frame   = new Frame();
            string lastUrl = backUrl.Last();

            backUrl.Remove(lastUrl);
            switch (parseUrl(lastUrl))
            {
            case "planets":
                PlanetPage planetPage  = new PlanetPage(lastUrl, backUrl);
                Frame      planetFrame = new Frame();
                frame.Content = planetPage;
                break;

            case "species":
                SpeciesPage speciesPage  = new SpeciesPage(lastUrl, backUrl);
                Frame       speciesFrame = new Frame();
                frame.Content = speciesPage;
                break;

            case "vehicles":
                VehiclePage vehiclePage = new VehiclePage(lastUrl, backUrl);
                frame.Content = vehiclePage;
                break;

            case "starships":
                StarshipPage starshipPage = new StarshipPage(lastUrl, backUrl);
                frame.Content = starshipPage;
                break;

            case "people":
                PeoplePage peoplePage = new PeoplePage(lastUrl, backUrl);
                frame.Content = peoplePage;
                break;

            case "films":
                FilmPage filmPage = new FilmPage(lastUrl, backUrl);
                frame.Content = filmPage;
                break;
            }
            return(frame);
        }
Exemplo n.º 5
0
        public IActionResult Index()
        {
            List <FilmPage> RecomendsList = new List <FilmPage>();
            List <FilmPage> FilmsList     = new List <FilmPage>();
            FilmPage        RecomendFilm  = new FilmPage {
                FilmViews = 0, InFavList = 0
            };

            using (MyDbContext db = new MyDbContext())
            {
                FilmsList = db.FilmPages.ToList();
                for (int i = 0; i < FilmsList.Count; i++)
                {
                    foreach (var film in FilmsList)
                    {
                        //If film alredy exist in recomend list loop skip it
                        if (RecomendsList.FirstOrDefault(a => a == film) == null)
                        {
                            //If film in list has got more "PopularPoints" then film in RecomendFilm it becomes recomend film
                            //PopularPoint is views * (how many add this film in favourite list * 100)
                            //Second term multiplies to 100 because it's more important
                            if (film.FilmViews * (film.InFavList * 100) >= RecomendFilm.FilmViews * (RecomendFilm.InFavList * 100))
                            {
                                RecomendFilm = film;
                            }
                        }
                    }
                    RecomendsList.Add(RecomendFilm);
                    RecomendFilm = new FilmPage {
                        FilmViews = 0, InFavList = 0
                    };
                }
            }
            ViewData["Films"] = RecomendsList;
            return(View());
        }
Exemplo n.º 6
0
        private void CallPage(object sender, MouseEventArgs e)
        {
            List <String> backUrl = new List <String>();

            backUrl.Add("");
            switch (ListElements.SelectedItem.GetType().ToString())
            {
            case "OpenFood_C_Sharp.Modele.People":
                b         = new Button();
                b.Content = " X ";
                People     p               = (People)ListElements.SelectedItem;
                PeoplePage peoplePage      = new PeoplePage(p.url, backUrl);
                Frame      peoplePageFrame = new Frame();
                peoplePageFrame.Content = peoplePage;
                tabItem   = new TabItem();
                stack     = new StackPanel();
                l         = new Label();
                l.Content = p.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = peoplePageFrame;
                mainTab.Items.Add(tabItem);
                b.Click += removePanel;
                b.Tag    = tabItem;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;

            case "OpenFood_C_Sharp.Modele.Film":
                b         = new Button();
                b.Content = " X ";
                Film     f             = (Film)ListElements.SelectedItem;
                FilmPage filmPage      = new FilmPage(f.url, backUrl);
                Frame    filmPageFrame = new Frame();
                filmPageFrame.Content = filmPage;
                tabItem   = new TabItem();
                stack     = new StackPanel();
                l         = new Label();
                l.Content = f.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = filmPageFrame;
                mainTab.Items.Add(tabItem);
                b.Tag    = tabItem;
                b.Click += removePanel;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;

            case "OpenFood_C_Sharp.Modele.Starship":
                b         = new Button();
                b.Content = " X ";
                Starship     star           = (Starship)ListElements.SelectedItem;
                StarshipPage starshipPage   = new StarshipPage(star.url, backUrl);
                Frame        starsShipFrame = new Frame();
                starsShipFrame.Content = starshipPage;
                tabItem = new TabItem();
                stack   = new StackPanel();

                l         = new Label();
                l.Content = star.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = starsShipFrame;
                mainTab.Items.Add(tabItem);
                b.Tag    = tabItem;
                b.Click += removePanel;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;

            case "OpenFood_C_Sharp.Modele.Vehicle":
                b         = new Button();
                b.Content = " X ";
                Vehicle     v             = (Vehicle)ListElements.SelectedItem;
                VehiclePage vehiclePage   = new VehiclePage(v.url, backUrl);
                Frame       vehiculeFrame = new Frame();
                vehiculeFrame.Content = vehiclePage;
                tabItem   = new TabItem();
                stack     = new StackPanel();
                l         = new Label();
                l.Content = v.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = vehiculeFrame;
                mainTab.Items.Add(tabItem);
                b.Tag    = tabItem;
                b.Click += removePanel;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;

            case "OpenFood_C_Sharp.Modele.Species":
                b         = new Button();
                b.Content = " X ";
                Species     s            = (Species)ListElements.SelectedItem;
                SpeciesPage speciesPage  = new SpeciesPage(s.url, backUrl);
                Frame       speciesFrame = new Frame();
                speciesFrame.Content = speciesPage;
                tabItem   = new TabItem();
                stack     = new StackPanel();
                l         = new Label();
                l.Content = s.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = speciesFrame;
                mainTab.Items.Add(tabItem);
                b.Tag    = tabItem;
                b.Click += removePanel;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;

            case "OpenFood_C_Sharp.Modele.Planet":
                b         = new Button();
                b.Content = " X ";
                Planet     pla         = (Planet)ListElements.SelectedItem;
                PlanetPage planetPage  = new PlanetPage(pla.url, backUrl);
                Frame      planetFrame = new Frame();
                planetFrame.Content = planetPage;
                tabItem             = new TabItem();
                stack     = new StackPanel();
                l         = new Label();
                l.Content = pla.ToString();
                stack.Children.Add(l);
                stack.Children.Add(b);
                stack.Orientation = Orientation.Horizontal;
                tabItem.Header    = stack;
                tabItem.Content   = planetFrame;
                mainTab.Items.Add(tabItem);
                b.Click += removePanel;
                mainTab.SelectedItem = tabItem;
                mainTab.Visibility   = Visibility.Visible;
                break;
            }
        }