コード例 #1
0
 protected override void UpdateTotals()
 {
     if (ItemsShowing.Count == 0)
     {
         AveragePreference   = 0;
         AverageProfitMargin = 0;
         return;
     }
     AveragePreference   = ItemsShowing.Average(x => x.Preference);
     AverageProfitMargin = ItemsShowing.Average(x => x.ProfitMargin);
 }
コード例 #2
0
        protected override void UpdateTotals()
        {
            if (ItemsShowing.Count() == 0)
            {
                Minimum = Maximum = Average = 0;
                return;
            }

            Minimum = ItemsShowing.Min(x => x.MinimumQuantity * x.MinimumUnitMeasure.ToBaseConversion);
            Maximum = ItemsShowing.Max(x => x.MaximumQuantity * x.MaximumUnitMeasure.ToBaseConversion);
            Average = Math.Round(ItemsShowing.Average(x => x.AverageQuantity * x.AverageUnitMeasure.ToBaseConversion));

            //fit qtties
            var invSvc = base.GetService <IInventoryService>();

            using (var unitOfWork = base.GetNewUnitOfWork())
            {
                Product selectedProduct = Products.Single(x => x.Id == SelectedProductId);

                UMFamily    umf    = unitOfWork.UMFamilyRepository.GetById(selectedProduct.UMFamilyId);
                UnitMeasure bestUM = invSvc.GetBestUM(umf, Minimum);

                MinUnitMeasure = bestUM;
                Minimum        = Minimum / bestUM.ToBaseConversion;

                bestUM = invSvc.GetBestUM(umf, Maximum);

                MaxUnitMeasure = bestUM;
                Maximum        = Maximum / bestUM.ToBaseConversion;

                bestUM = invSvc.GetBestUM(umf, Average);

                AveUnitMeasure = bestUM;

                int decimalPlaces = umf.Id == 1 ? 0 : 2;
                Average = Math.Round(Average / bestUM.ToBaseConversion, decimalPlaces);
            }
        }