Exemplo n.º 1
0
        public ActionResult Index()
        {
            MoviesView mService = new MoviesView();
            var        result   = mService.getMaster();

            return(View(result));
        }
Exemplo n.º 2
0
        public ActionResult Season(String id)
        {
            MoviesView mService = new MoviesView();
            var        result   = mService.getSeaSon(id);

            return(View(result));
        }
Exemplo n.º 3
0
        public List <Movie> GetNotYetFriendsList(Friends Friends, MoviesView contacts)
        {
            List <Movie> ContactNotYetFriendsList = new List <Movie>();
            List <Movie> FriendsList = GetFriendsList(Friends, contacts);
            List <Movie> ContactList = contacts.ToList();

            foreach (Movie movie in ContactList)
            {
                bool isFriend = false;
                foreach (Movie friend in FriendsList)
                {
                    if (movie.Id == friend.Id)
                    {
                        isFriend = true;
                        break;
                    }
                }
                if (!isFriend)
                {
                    ContactNotYetFriendsList.Add(contacts.Get(movie.Id).Clone());
                }
            }

            return(ContactNotYetFriendsList);
        }
Exemplo n.º 4
0
        public ActionResult Edit(String id)
        {
            // Make sure that this action is called with an id
            if (!String.IsNullOrEmpty(id))
            {
                Movie movieToEdit = ((Movies)HttpRuntime.Cache["Movies"]).Get(int.Parse(id));

                // Make sure the contact exist
                if (movieToEdit != null)
                {
                    // Retreive from the Session dictionary the reference of the ContactsView instance
                    MoviesView moviesView = (MoviesView)Session["MoviesView"];

                    // Retreive from the Application dictionary the reference of the Friends instance
                    Friends Friends = (Friends)HttpRuntime.Cache["Friends"];

                    // Store in ViewBag the friend list of the contact to edit
                    ViewBag.FriendsList = movieToEdit.GetFriendsList(Friends, moviesView);

                    // Store in ViewBag the "not yet friend" contact list  of the contact to edit
                    ViewBag.NotYetFriendsList = movieToEdit.GetNotYetFriendsList(Friends, moviesView);

                    // Pass the contact to edit reference to this action view
                    return(View(movieToEdit));
                }
            }

            // Return the Index action of this controller
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        // GET
        public IActionResult Index(int postedBy, string orderBy)
        {
            var movies = _movieService.GetMoviesWithUserVote(CurrentUserId);
            var moviesQ = movies
                .Where(movie => postedBy > 0
                    ? movie.PostedByUserId == postedBy
                    : movie.PostedByUserId > 0);

            switch (orderBy)
            {
                case "likes":
                    moviesQ = moviesQ.OrderBy(movie => movie.Likes);
                    break;
                case "hates":
                    moviesQ = moviesQ.OrderBy(movie => movie.Hates);
                    break;
                case "date":
                    moviesQ = moviesQ.OrderBy(movie => movie.PublishedDate);
                    break;
            }

            var moviesView = new MoviesView
            {
                Movies =
                    moviesQ
                        .ToList()
                        .ToMoviesView(CurrentUserId),
                CanAddMovie = HttpContext.User.Identity.IsAuthenticated
            };
            return View(moviesView);
        }
Exemplo n.º 6
0
        public ActionResult Episode(String id)
        {
            MoviesView mService          = new MoviesView();
            var        result            = mService.getEpisode(id);
            Totaltime  tt                = new Totaltime();
            var        Movies_Total_Time = new TimeSpan(result.Sum(r => r.Time.Ticks));

            tt.total = new TimeSpan(result.Sum(r => r.Time.TimeOfDay.Ticks));
            return(View(tt));
        }
Exemplo n.º 7
0
        public JsonResult MasterList()
        {
            MoviesView mService = new MoviesView();
            var        result   = mService.getMaster();
            var        Obj      = new
            {
                data = result
            };
            var jsonResult = Json(Obj, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength   = int.MaxValue;
            jsonResult.ContentType     = "application/json";
            jsonResult.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
            return(jsonResult);
        }
Exemplo n.º 8
0
        public List <Movie> GetFriendsList(Friends Friends, MoviesView contacts)
        {
            List <Movie>  ContactFriendsList = new List <Movie>();
            List <Friend> FriendsList        = Friends.ToList();

            foreach (Friend Friend in FriendsList)
            {
                if (this.Id == Friend.ContactId)
                {
                    ContactFriendsList.Add(contacts.Get(Friend.FriendId).Clone());
                }
            }

            return(ContactFriendsList);
        }
Exemplo n.º 9
0
        private void LoadAllMoviesViewModel(MoviesView view)
        {
            IEnumerable<string> images = view.MovieItems.Take(1).Select(i => _apiClient.GetImageUrl(i.Id, new ImageOptions {
                ImageType = i.ImageType,
                Tag = i.ImageTag,
                Height = Convert.ToInt32(HomeViewModel.TileWidth*2),
                EnableImageEnhancers = false
            }));

            AllMoviesImagesViewModel.Images.AddRange(images);
            AllMoviesImagesViewModel.StartRotating();
        }
Exemplo n.º 10
0
 private void LoadSpotlightViewModel(MoviesView view)
 {
     SpotlightViewModel.Items = view.SpotlightItems;
 }
Exemplo n.º 11
0
        private void LoadMiniSpotlightsViewModel(MoviesView view)
        {
            BaseItemDto[] items = view.MiniSpotlights.Take(3).ToArray();

            for (int i = 0; i < items.Length; i++) {
                if (MiniSpotlightItems.Count > i) {
                    MiniSpotlightItems[i].Item = items[i];
                } else {
                    ItemTileViewModel vm = CreateMiniSpotlightItem();
                    vm.Item = items[i];

                    MiniSpotlightItems.Add(vm);
                }
            }

            if (MiniSpotlightItems.Count > items.Length) {
                List<ItemTileViewModel> toRemove = MiniSpotlightItems.Skip(items.Length).ToList();
                MiniSpotlightItems.RemoveRange(toRemove);
            }
        }
Exemplo n.º 12
0
 protected void Session_Start()
 {
     // Keep the reference of the ContactsView in order to allow all the controllers and views have access to it
     // This allows all the session to have their own sorted contact list
     Session["MoviesView"] = new MoviesView((Movies)HttpRuntime.Cache["Movies"]);
 }
Exemplo n.º 13
0
        public App()
        {
            InitializeComponent();

            MainPage = new MoviesView();
        }
Exemplo n.º 14
0
        public static void Main(string[] args)
        {
            MoviesView view   = new MoviesView();
            bool       repeat = true;

            Console.WriteLine("This program contains the CRUD(Create, Read, Update & Delete) of some Movies");
            Console.WriteLine("Catalogo de Peliculas:");

            do
            {
                Console.WriteLine("Elige una opcion:");
                int     i        = 0;                    //contador para las opciones
                int     selected = 0;                    //opcion seleccionada
                DataSet dts      = new DataSet("HW2DB"); //nombre de la base
                Movie   m        = new Movie();


                string[] options = new string[]//asignamos las opciones
                {
                    "Alta", "Consulta", "Baja", "SALIR"
                };
                foreach (string opt in options)//ahora imprimimos las opciones
                {
                    Console.WriteLine((i + 1) + ") " + opt);
                    i++;
                }
                ;

                try                                                 //para tener una ecxepcion
                {
                    selected = Convert.ToInt32(Console.ReadLine()); //leer el seleccionado

                    switch (selected)                               //que hacer con cada opción
                    {
                    case 1:
                        view.AddMovie();    //agregar pelicula
                        break;

                    case 2:
                        view.DisplayMovies();    //mostrar peliculas
                        break;

                    case 3:
                        view.DeleteMovie();    //Borrar pelicula
                        break;

                    case 4:
                        Console.WriteLine("BYE!");    //salir
                        repeat = false;
                        break;

                    default:
                        Console.WriteLine("Elige una opcion válida");    //en caso de una opcion invalida
                        break;
                    }
                }
                catch (FormatException)// añadimos una excepcion
                {
                    Console.WriteLine("error, elige una opcion numerica");
                }
            } while (repeat);//al terminar repite
        }