Esempio n. 1
0
        void UpdateSources(List <ImageSource> discIcons)
        {
            if (VRObjectEditObject.VideoRentObject == null)
            {
                return;
            }
            MovieItemFormat[]  formats       = EnumHelper.GetValues <MovieItemFormat>();
            MovieItemFormat?[] formatsAndAll = new MovieItemFormat?[formats.Length + 1];
            for (int i = 0; i < formats.Length; ++i)
            {
                formatsAndAll[i] = formats[i];
            }
            formatsAndAll[formatsAndAll.Length - 1] = null;
            MovieItem.CountInfo           countInfo   = new MovieItem.CountInfo(VRObjectEditObject.VideoRentObject.Items);
            List <MovieFormatInfo>        formatInfos = new List <MovieFormatInfo>();
            List <RentalsChartSourceItem> rentals     = new List <RentalsChartSourceItem>();

            for (int i = 0; i < formatsAndAll.Length; ++i)
            {
                MovieCategoryPrice categoryPrice = formatsAndAll[i] == null ? null : VRObjectEditObject.VideoRentObject.Category.GetPrice(formatsAndAll[i].Value);
                ImageSource        formatImage   = i == formatsAndAll.Length - 1 ? null : discIcons[i];
                MovieFormatInfo    info          = new MovieFormatInfo(formatsAndAll[i], countInfo, categoryPrice, formatImage);
                formatInfos.Add(info);
                rentals.Add(new RentalsChartSourceItem(info.FormatText, info.FormatDetailsDictionary));
            }
            UpdateSourcesFields(countInfo, formatInfos, rentals);
        }
Esempio n. 2
0
 public MovieFormatInfo(MovieItemFormat?format, MovieItem.CountInfo countInfo, MovieCategoryPrice categoryPrice, ImageSource formatIcon)
 {
     CategoryPrice = categoryPrice;
     CountInfo     = countInfo;
     Format        = format;
     FormatIcon    = formatIcon;
     UpdateFields();
 }
Esempio n. 3
0
        static object GetPropertyValueByName(MovieCategoryPrice price, string propertyName)
        {
            PropertyInfo propertyInfo;

            if (!propertyInfos.TryGetValue(propertyName, out propertyInfo))
            {
                propertyInfo = typeof(MovieCategoryPrice).GetProperty(propertyName);
                propertyInfos.Add(propertyName, propertyInfo);
            }
            return(propertyInfo.GetValue(price, null));
        }
Esempio n. 4
0
 void UpdateAllPoints(MovieCategoryPrice price)
 {
     for (int i = 1; i < 8; ++i)
     {
         string      fieldName = string.Format(fieldNamePattern, i);
         string      key       = string.Format(pointsKeyPattern, price.Format, fieldName);
         SeriesPoint point     = null;
         if (pointsDictionary.TryGetValue(key, out point))
         {
             point.Value = GetPropertyValueByNameWithEnsure(price, fieldName);
         }
     }
 }
Esempio n. 5
0
        void UpdatePoint(MovieCategoryPrice price, string fieldName)
        {
            SeriesPoint point = null;

            if (fieldName == reserveFieldName)
            {
                UpdateAllPoints(price);
            }
            else
            {
                if (!string.IsNullOrEmpty(fieldName) && pointsDictionary.TryGetValue(string.Format(pointsKeyPattern, ((MovieCategoryPrice)price).Format, fieldName), out point))
                {
                    point.Value = GetPropertyValueByNameWithEnsure(price, fieldName);
                }
            }
        }
Esempio n. 6
0
        public void MovieItem_CalcOnOrderPrice()
        {
            MovieCategory      newFilms      = new MovieCategory(Session);
            MovieCategoryPrice newFilmsOnDVD = newFilms.GetPrice(MovieItemFormat.DVD);

            newFilmsOnDVD.LateRentPrice  = 4;
            newFilmsOnDVD.Days1RentPrice = 2;
            newFilmsOnDVD.Days2RentPrice = 1;
            Avatar.Category = newFilms;
            MovieItem avatarItem   = Avatar.Items[0];
            decimal   onOrderPrice = avatarItem.CalcOnOrderPrice(9);

            Assert.AreEqual(7 * 1 + (9 - 7) * 4, onOrderPrice);
            onOrderPrice = avatarItem.CalcOnOrderPrice(1);
            Assert.AreEqual(1 * 2, onOrderPrice);
        }
Esempio n. 7
0
        public void CreatingAndDeletingPrices()
        {
            MovieCategory category = new MovieCategory(Session);

            foreach (MovieItemFormat format in EnumHelper.GetValues <MovieItemFormat>())
            {
                MovieCategoryPrice price = category.GetPrice(MovieItemFormat.DVD);
                Assert.IsNotNull(price);
            }
            XPCollection <MovieCategoryPrice> prices = category.Prices;

            category.Delete();
            foreach (MovieCategoryPrice price in prices)
            {
                Assert.IsTrue(price.IsDeleted);
            }
        }
Esempio n. 8
0
        LineSeries2D GenerateSerie(MovieCategoryPrice price)
        {
            LineSeries2D serie = new LineSeries2D()
            {
                DisplayName = price.Format.ToString(), LabelsVisibility = true
            };

            for (int i = 1; i <= MovieCategoryPrice.TermsRentCount; ++i)
            {
                string      fieldName = string.Format(fieldNamePattern, i);
                string      key       = string.Format(pointsKeyPattern, price.Format, fieldName);
                SeriesPoint point     = null;
                if (!pointsDictionary.TryGetValue(key, out point))
                {
                    point = new SeriesPoint(i, GetPropertyValueByNameWithEnsure(price, fieldName));
                    pointsDictionary.Add(key, point);
                }
                serie.Points.Add(point);
            }
            UpdateSubscriptionToPropertyChanged(price);
            return(serie);
        }
Esempio n. 9
0
        public void MovieItem_CalcRentMaxDaysCount()
        {
            MovieCategory      newFilms      = new MovieCategory(Session);
            MovieCategoryPrice newFilmsOnDVD = newFilms.GetPrice(MovieItemFormat.DVD);

            newFilmsOnDVD.LateRentPrice  = 1;
            newFilmsOnDVD.Days1RentPrice = 2;
            newFilmsOnDVD.Days2RentPrice = 1;
            Avatar.Category = newFilms;
            MovieItem avatarItem = Avatar.Items[0];

            avatarItem.SellingPrice = 2;
            Assert.AreEqual(0, avatarItem.CalcRentMaxDaysCount());
            avatarItem.SellingPrice = 4;
            Assert.AreEqual(3, avatarItem.CalcRentMaxDaysCount());
            avatarItem.SellingPrice = 10;
            Assert.AreEqual(9, avatarItem.CalcRentMaxDaysCount());
            avatarItem.SellingPrice = 10.5m;
            Assert.AreEqual(10, avatarItem.CalcRentMaxDaysCount());
            avatarItem.AvailableForSell = false;
            Assert.AreEqual(-1, avatarItem.CalcRentMaxDaysCount());
        }
Esempio n. 10
0
        static double GetPropertyValueByNameWithEnsure(MovieCategoryPrice price, string propertyName)
        {
            object value = GetPropertyValueByName(price, propertyName);

            return(value == null || (double)(decimal)value == 0.0 ? (double)(decimal)(GetPropertyValueByName(price, reserveFieldName)) : (double)(decimal)value);
        }
Esempio n. 11
0
 protected override void DisposeManaged()
 {
     CategoryPrice = null;
     base.DisposeManaged();
 }
Esempio n. 12
0
 protected override void UpdateOverride()
 {
     CategoryPrice = MovieCategoryPriceEditObjectParent.GetCategoryPrice(categoryPriceOid);
 }