Exemplo 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);
        }
Exemplo n.º 2
0
 public MovieFormatInfo(MovieItemFormat?format, MovieItem.CountInfo countInfo, MovieCategoryPrice categoryPrice, ImageSource formatIcon)
 {
     CategoryPrice = categoryPrice;
     CountInfo     = countInfo;
     Format        = format;
     FormatIcon    = formatIcon;
     UpdateFields();
 }
Exemplo 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));
        }
Exemplo 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);
         }
     }
 }
Exemplo 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);
                }
            }
        }
Exemplo 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);
        }
Exemplo 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);
            }
        }
Exemplo 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);
        }
Exemplo 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());
        }
Exemplo 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);
        }
Exemplo n.º 11
0
 protected override void DisposeManaged()
 {
     CategoryPrice = null;
     base.DisposeManaged();
 }
Exemplo n.º 12
0
 protected override void UpdateOverride()
 {
     CategoryPrice = MovieCategoryPriceEditObjectParent.GetCategoryPrice(categoryPriceOid);
 }