public Recommendation GetRecommendationByMedia(Media pMedia)
 {
     using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
     {
         Recommendation recommendation = lContainer.Recommendations.Where((pRecommendation) => pRecommendation.Medium.Id == pMedia.Id).FirstOrDefault();
         return recommendation;
     }
 }
Beispiel #2
0
 public void AddItem(Media pMedia, int pQuantity)
 {
     var lItem = mOrderItems.FirstOrDefault(oi => oi.Media.Id == pMedia.Id);
     if (lItem == null)
     {
         mOrderItems.Add(new OrderItem() { Media = pMedia, Quantity = pQuantity });
     }
     else
     {
         lItem.Quantity += pQuantity;
     }
 }
 public bool IsMediaLikedByUser(Media pMedia, User pUser)
 {
     //get the medias this user liked before
     List<Media> mList = this.GetMediumUserLikes(pUser.Id);
     bool b =  false;
     foreach(Media m in mList){
         if (m.Id == pMedia.Id) {
             b = true;
         }
     }
     return b;
 }
Beispiel #4
0
 public void RemoveLine(Media pMedia)
 {
     mOrderItems.RemoveAll(oi => oi.Media.Id == pMedia.Id);
 }
Beispiel #5
0
        private void FixupMedia(Media previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Media")
                    && (ChangeTracker.OriginalValues["Media"] == Media))
                {
                    ChangeTracker.OriginalValues.Remove("Media");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Media", previousValue);
                }
                if (Media != null && !Media.ChangeTracker.ChangeTrackingEnabled)
                {
                    Media.StartTracking();
                }
                FixupMediaKeys();
            }
        }
Beispiel #6
0
        private void FixupMedia(Media previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && ReferenceEquals(previousValue.Stocks, this))
            {
                previousValue.Stocks = null;
            }

            if (Media != null)
            {
                Media.Stocks = this;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Media")
                    && (ChangeTracker.OriginalValues["Media"] == Media))
                {
                    ChangeTracker.OriginalValues.Remove("Media");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Media", previousValue);
                }
                if (Media != null && !Media.ChangeTracker.ChangeTrackingEnabled)
                {
                    Media.StartTracking();
                }
            }
        }
 public ListReviewsViewModel(int pMediaId)
 {
     Media = new CatalogueServiceClient().GetMediaById(pMediaId);
 }
        private void FixupMedium(Media previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && ReferenceEquals(previousValue.Recommendation, this))
            {
                previousValue.Recommendation = null;
            }

            if (Medium != null)
            {
                Medium.Recommendation = this;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Medium")
                    && (ChangeTracker.OriginalValues["Medium"] == Medium))
                {
                    ChangeTracker.OriginalValues.Remove("Medium");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Medium", previousValue);
                }
                if (Medium != null && !Medium.ChangeTracker.ChangeTrackingEnabled)
                {
                    Medium.StartTracking();
                }
                FixupMediumKeys();
            }
        }
 public bool IsMediaLikedByUser(Media pMedia,User pUser)
 {
     return CatalogueProvider.IsMediaLikedByUser(pMedia,pUser);
 }
Beispiel #10
0
        private static void InsertCatalogueEntities()
        {
            using (TransactionScope lScope = new TransactionScope())
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                if (lContainer.Medias.Count() == 0)
                {
                    Media lGreatExpectations = new Media()
                    {
                        Director = "Rene Clair",
                        Genre = "Fiction",
                        Price = 20.0M,
                        Title = "And Then there were None",
                        UPC="A"
                    };

                    //lContainer.Media.AddObject(lGreatExpectations);
                    //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                    //    CommandFactory.Instance.GetEntityInsertCommand<Media>(lGreatExpectations)
                    //);

                    Stock lGreatExpectationsStock = new Stock()
                    {
                        Media = lGreatExpectations,

                        // NEWLY ADDED
                        MediaId = lGreatExpectations.Id,


                        Holding = 5,
                        Warehouse = "Neutral Bay",
                        Quantity = 1
                    };

                    //lContainer.Stocks.AddObject(lGreatExpectationsStock);
                    //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                    //    CommandFactory.Instance.GetEntityInsertCommand<Stock>(lGreatExpectationsStock)
                    //);
                    ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                        CommandFactory.Instance.GetEntityInsertCommand<Media>(lGreatExpectations)
                    );


                    Media lSoloist = new Media()
                    {
                        Director = "The Soloist",
                        Genre = "Fiction",
                        Price = 15.0M,
                        Title = "The Soloist",
                        UPC="B"
                    };

                    //lContainer.Media.AddObject(lSoloist);
                    //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                    //    CommandFactory.Instance.GetEntityInsertCommand<Media>(lSoloist)
                    //);


                    Stock lSoloistStock = new Stock()
                    {
                        Media = lSoloist,

                        // NEWLY ADDED
                        MediaId = lSoloist.Id,

                        Holding = 7,
                        Warehouse = "Neutral Bay",
                        Quantity = 1
                    };

                    //lContainer.Stocks.AddObject(lSoloistStock);
                    //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                    //    CommandFactory.Instance.GetEntityInsertCommand<Stock>(lSoloistStock)
                    //);
                    ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                        CommandFactory.Instance.GetEntityInsertCommand<Media>(lSoloist)
                    );



                    for (int i = 0; i < 30; i++)
                    {
                        Media lItem = new Media()
                        {
                            Director = String.Format("Director {0}", i.ToString()),
                            Genre = String.Format("Genre {0}", i),
                            Price = i,
                            Title = String.Format("Title {0}", i),
                            UPC = i.ToString()
                        };

                        //lContainer.Media.AddObject(lItem);
                        //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                        //    CommandFactory.Instance.GetEntityInsertCommand<Media>(lItem)
                        //);

                        Stock lStock = new Stock()
                        {
                            Media = lItem,

                            // NEWLY ADDED
                            //MediaId = lItem.Id,


                            Holding = 7,
                            Warehouse = String.Format("Warehouse {0}", i),
                            Quantity = 1
                        };

                        //lContainer.Stocks.AddObject(lStock);
                        //ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                        //    CommandFactory.Instance.GetEntityInsertCommand<Stock>(lStock)
                        //);
                        ServiceLocator.Current.GetInstance<IPublisherService>().Publish(
                            CommandFactory.Instance.GetEntityInsertCommand<Media>(lItem)
                        );

                    }


                    //lContainer.SaveChanges();
                    lScope.Complete();
                }

                

            }

        }
Beispiel #11
0
        private void FixupMedium(Media previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.LikeMatching.Contains(this))
            {
                previousValue.LikeMatching.Remove(this);
            }

            if (Medium != null)
            {
                if (!Medium.LikeMatching.Contains(this))
                {
                    Medium.LikeMatching.Add(this);
                }

            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Medium")
                    && (ChangeTracker.OriginalValues["Medium"] == Medium))
                {
                    ChangeTracker.OriginalValues.Remove("Medium");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Medium", previousValue);
                }
                if (Medium != null && !Medium.ChangeTracker.ChangeTrackingEnabled)
                {
                    Medium.StartTracking();
                }
                FixupMediumKeys();
            }
        }
 /* simply return a LikeMatching object which matches to the given media */
 private LikeMatching GetLikeMatchingMediaIn(Media pMedia, List<LikeMatching> LikeMatchingList)
 {
     foreach (LikeMatching pLikeMatching in LikeMatchingList)
     {
         if (pLikeMatching.Medium.Id == pMedia.Id)
         {
             return pLikeMatching;
         }
     }
     return null;
 }
 public MediaWithLikeStatus(Media pMedia,bool liked)
 {
     this.Liked = liked;
     this.pMedia = pMedia;
 }
 private bool IsMediaLikedByUser(Media pMedia)
 {
     return this.CatalogueService.IsMediaLikedByUser(pMedia,CurrentUser);
 }
Beispiel #15
0
        private static void InsertCatalogueEntities()
        {
            using (TransactionScope lScope = new TransactionScope())
            using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
            {
                if (lContainer.Media.Count() == 0)
                {
                    Media lGreatExpectations = new Media()
                    {
                        Director = "Rene Clair",
                        Genre = "Fiction",
                        Price = 20.0M,
                        Title = "And Then there were None"
                    };

                    lContainer.Media.AddObject(lGreatExpectations);

                    Stock lGreatExpectationsStock = new Stock()
                    {
                        Media = lGreatExpectations,
                        Holding = 5,
                        Warehouse = "Neutral Bay"
                    };

                    lContainer.Stocks.AddObject(lGreatExpectationsStock);

                    Media lSoloist = new Media()
                    {
                        Director = "The Soloist",
                        Genre = "Fiction",
                        Price = 15.0M,
                        Title = "The Soloist"
                    };

                    lContainer.Media.AddObject(lSoloist);

                    Stock lSoloistStock = new Stock()
                    {
                        Media = lSoloist,
                        Holding = 7,
                        Warehouse = "Neutral Bay"
                    };

                    lContainer.Stocks.AddObject(lSoloistStock);

                    for (int i = 0; i < 30; i++)
                    {
                        Media lItem = new Media()
                        {
                            Director = String.Format("Director {0}", i.ToString()),
                            Genre = String.Format("Genre {0}", i),
                            Price = i,
                            Title = String.Format("Title {0}", i)
                        };

                        lContainer.Media.AddObject(lItem);

                        Stock lStock = new Stock()
                        {
                            Media = lItem,
                            Holding = 7,
                            Warehouse = String.Format("Warehouse {0}", i)
                        };

                        lContainer.Stocks.AddObject(lStock);
                    }

                    lContainer.SaveChanges();
                    lScope.Complete();
                }

            }
        }