コード例 #1
0
 public Recommendation GetRecommendationByMedia(Media pMedia)
 {
     using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
     {
         Recommendation recommendation = lContainer.Recommendations.Where((pRecommendation) => pRecommendation.Medium.Id == pMedia.Id).FirstOrDefault();
         return recommendation;
     }
 }
コード例 #2
0
ファイル: Cart.cs プロジェクト: fengyu25/comp5348
 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;
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: Cart.cs プロジェクト: fengyu25/comp5348
 public void RemoveLine(Media pMedia)
 {
     mOrderItems.RemoveAll(oi => oi.Media.Id == pMedia.Id);
 }
コード例 #5
0
ファイル: Stock.cs プロジェクト: votrongdao/VideoStore
        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();
            }
        }
コード例 #6
0
ファイル: Stock.cs プロジェクト: agaw/aurora
        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();
                }
            }
        }
コード例 #7
0
 public ListReviewsViewModel(int pMediaId)
 {
     Media = new CatalogueServiceClient().GetMediaById(pMediaId);
 }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
 public bool IsMediaLikedByUser(Media pMedia,User pUser)
 {
     return CatalogueProvider.IsMediaLikedByUser(pMedia,pUser);
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: fengyu25/comp5348
        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();
                }

                

            }

        }
コード例 #11
0
ファイル: LikeMatching.cs プロジェクト: votrongdao/VideoStore
        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();
            }
        }
コード例 #12
0
 /* 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;
 }
コード例 #13
0
 public MediaWithLikeStatus(Media pMedia,bool liked)
 {
     this.Liked = liked;
     this.pMedia = pMedia;
 }
コード例 #14
0
 private bool IsMediaLikedByUser(Media pMedia)
 {
     return this.CatalogueService.IsMediaLikedByUser(pMedia,CurrentUser);
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: votrongdao/VideoStore
        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();
                }

            }
        }