예제 #1
0
        private SelectListItem[] GetVideoDirectors()
        {
            List <SelectListItem> list = new List <SelectListItem>();

            // Load the Video Collection from Session
            Collection <Video> myCollection = Session["VideoCollection"] as Collection <Video>;

            // Check to See if the Video Collection is New or Empty
            if (myCollection == null)
            {
                myCollection = VideoFactory.GetCollection();
                //Add the Factory to the Session
                Session["VideoCollection"] = myCollection;
            }

            foreach (Video video in myCollection)
            {
                list.Add(new SelectListItem()
                {
                    Text     = video.Director,
                    Value    = video.Director,
                    Selected = false
                });
            }

            return(list.ToArray());
        }
예제 #2
0
        public ActionResult Details(int id)
        {
            // Load the Video Collection from Session
            Collection <Video> myCollection = Session["VideoCollection"] as Collection <Video>;

            // Check to See if the Video Collection is New or Empty
            if (myCollection == null)
            {
                myCollection = VideoFactory.GetCollection();
                //Add the Factory to the Session
                Session["VideoCollection"] = myCollection;
            }

            // Create Ienumerable Collection for LINQ Query
            IEnumerable <Video> mySearchResults = myCollection;

            // Find the Video Model with the Matching ID
            mySearchResults = mySearchResults.Where(v => v.VideoId == id);

            // Convert the Search Results to a Collection
            Collection <Video> mySearchCollection = new Collection <Video>(mySearchResults.ToList <Video>());

            // Return the View
            return(View(mySearchCollection));
        }
예제 #3
0
        public void TestOtherVideoProduct()
        {
            ProductFactory productFactory = new VideoFactory();
            Product        video          = productFactory.Create("Movie");

            Assert.AreEqual(1, orderProcessor.ProcessOrder(video));
            //Free video should not be added.
            Assert.AreEqual(1, video.Outputs[0].Products.Count);
        }
예제 #4
0
        public void TestSkiVideoProduct()
        {
            ProductFactory productFactory = new VideoFactory();
            Product        video          = productFactory.Create("Learning To Ski");

            Assert.AreEqual(1, orderProcessor.ProcessOrder(video));

            //Also assert if free video was added.
            Assert.AreEqual(2, video.Outputs[0].Products.Count);
        }
예제 #5
0
 public override int SendToTarget()
 {
     if (Products[0].Description == "Learning To Ski")
     {
         Console.WriteLine("Adding free First Aid Video");
         ProductFactory productFactory = new VideoFactory();
         Product        video          = productFactory.Create("First Aid");
         Products.Add(video);
     }
     return(base.SendToTarget());
 }
예제 #6
0
        private void LoadVideo()
        {
            VideoFactory videoFactory = VideoFactory.Instance;

            videoFactory.LoadLabel("resources/label.xml");
            var videos = videoFactory.GetVideoes();

            TotalVideos = videos
                          .Select(v => new VideoModel(v)).ToList();

            Videos = new ObservableCollection <VideoModel>(TotalVideos);
        }
예제 #7
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                _mediaLibrary.AddRange(new FileSystemConnector().ReadXml());
            }
            return(_mediaLibrary);
        }
예제 #8
0
        public ActionResult Results(FormCollection frm)
        {
            // Take Results from the Form
            string title    = frm["TitleSearch"];
            string year     = frm["YearSearch"];
            string director = frm["DirectorSearch"];

            //TODO
            // Validate User Input Entry - Year

            // Load the Video Collection from Session
            Collection <Video> myCollection = Session["VideoCollection"] as Collection <Video>;

            // Check to See if the Video Collection is New or Empty
            if (myCollection == null)
            {
                myCollection = VideoFactory.GetCollection();
                //Add the Factory to the Session
                Session["VideoCollection"] = myCollection;
            }

            // Create Ienumerable Collection for LINQ Query
            IEnumerable <Video> mySearchResults = myCollection;

            // Filter Results on Title (If Exists)
            if (!String.IsNullOrWhiteSpace(title))
            {
                mySearchResults = mySearchResults.Where(v => v.Title.ToLower().Contains(title.ToLower()));
            }

            // Filter Results on Year (If Exists)
            if (!String.IsNullOrWhiteSpace(year))
            {
                int yearValid;
                if (int.TryParse(year, out yearValid))
                {
                    mySearchResults = mySearchResults.Where(v => v.Year == yearValid);
                }
            }

            // Filter Results on Director (If Exists)
            if (!String.IsNullOrWhiteSpace(director))
            {
                mySearchResults = mySearchResults.Where(v => v.Director == director);
            }

            // Convert the Search Results to a Collection
            Collection <Video> mySearchCollection = new Collection <Video>(mySearchResults.ToList <Video>());

            // Return the View
            return(View(mySearchCollection));
        }
예제 #9
0
        static void Main(string[] args)
        {
            ProductFactory factory = null;

            Console.Write("Enter the product type you would like to process: ");
            string pro = Console.ReadLine();

            Console.Write("Enter the product name you would like to process: ");
            string name = Console.ReadLine();

            Console.WriteLine("*********************");
            switch (pro.ToLower())
            {
            case "mobile":
                factory = new MobileFactory(name.ToLower());
                break;

            case "book":
                factory = new BookFactory(name.ToLower());
                break;

            case "video":
                factory = new VideoFactory(name.ToLower());
                break;

            case "new membership":
                factory = new NewMemberFactory(name.ToLower());
                break;

            case "upgrade membership":
                factory = new UpgradeMemberFactory(name.ToLower());
                break;

            default:
                break;
            }
            if (factory != null)
            {
                Product prod = factory.GetPayment();
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Product need to be added to repository");
                Console.ReadLine();
            }
        }
예제 #10
0
        public ActionResult Index()
        {
            // Load the Video Collection from Session
            Collection <Video> myCollection = Session["VideoCollection"] as Collection <Video>;

            // Check to See if the Video Collection is New or Empty
            if (myCollection == null)
            {
                myCollection = VideoFactory.GetCollection();
                //Add the Factory to the Session
                Session["VideoCollection"] = myCollection;
            }

            ViewData["Directors"] = GetVideoDirectors();

            return(View(myCollection));
        }
예제 #11
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                _mediaLibrary.AddRange(new AMedia[]
                {
                    audioFactory.Create <Book>(),
                    audioFactory.Create <Song>(),
                    videoFactory.Create <Movie>(),
                    videoFactory.Create <Photo>()
                });
            }
            return(_mediaLibrary);
        }
예제 #12
0
        private List <AMedia> Initialize()
        {
            var audioFactory = new AudioFactory();
            var videoFactory = new VideoFactory();

            if (_mediaLibrary == null)
            {
                _mediaLibrary = new List <AMedia>();
                // _mediaLibrary.AddRange(new AMedia[]
                // {
                //   audioFactory.Create<Book>(),
                //   audioFactory.Create<Song>(),
                //   videoFactory.Create<Movie>(),
                //   videoFactory.Create<Photo>()
                // });
                _mediaLibrary.AddRange(new FileSystemConnector().ReadXml());
            }
            return(_mediaLibrary);
        }
예제 #13
0
        public Movie GetTrailerInformation(string search)
        {
            Movie movie = CacheHelper.GetValue(search) as Movie;

            if (movie == null)
            {
                movie = new Movie();
                IVideo youtubeTrailerService = VideoFactory.Get(VideoFactory.VideoTypes.Youtube);
                IMovie opendbTrailerService  = MovieDBFactory.Get(MovieDBFactory.MovieDBTypes.Opendb);

                movie = opendbTrailerService.GetMovieInformation(search);

                if (movie.Title != null)
                {
                    GetMovieSources(movie, youtubeTrailerService);
                }
            }
            return(movie);
        }
예제 #14
0
 public async Task <Stream> GetVideoByName(string name)
 {
     return(await _client.GetStreamAsync(VideoFactory.GetVideo(name)));
 }
        private static void MkvFileCreated(object sender, System.IO.FileSystemEventArgs e)
        {
            VideoFile video = VideoFactory.CreateVideoFile(sender, e);

            SaveVideoToDb(video);
        }