Esempio n. 1
0
        public override void Recreate()
        {
            var up = new Unpricing
            {
                DeferFee = 0,
                EndPricingDate = Quota.PricingEndDate,
                StartPricingDate = Quota.PricingStartDate,
                UnpricingQuantity = Quota.Quantity,
                QuotaId = Quota.Id
            };

            if (Quota.IsAutoGenerated && Quota.RelQuotaId != null)
            {
                var relQuota = CTX.Quotas.Single(o => o.Id == Quota.RelQuotaId);
                var un = CTX.Unpricings.FirstOrDefault(o => o.QuotaId == relQuota.Id && !o.IsDeleted);
                if (un != null)
                {
                    up.RelUnpricingId = un.Id;
                    up.IsAutoGenerated = true;
                }
            }

            CTX.Unpricings.AddObject(up);
            Quota.PricingStatus = (int) PricingStatus.NotAtAll;
        }
Esempio n. 2
0
        protected override void Create()
        {
            var unpricing = new Unpricing
                                {
                                    QuotaId = QuotaId,
                                    UnpricingQuantity = DeferQuantity,
                                    DeferDate = DeferDate,
                                    DeferFee = NewDeferFee,
                                    EndPricingDate = EndDate,
                                    Description = Description,
                                    UnpricingId = ParentUnpricingId
                                };

            var unpricingService = SvcClientManager.GetSvcClient<UnpricingServiceClient>(SvcType.UnpricingSvc);
            var parent = unpricingService.SelectById(new List<string>{"RelatedUnpricings"}, ParentUnpricingId);
            unpricing.DeferFee += parent == null ? 0 : parent.DeferFee;
            var newUn = unpricingService.DeferPricing(unpricing, CurrentUser.Id);

            if (parent.RelatedUnpricings != null)
            {
                foreach (var un in parent.RelatedUnpricings)
                {
                    unpricing.QuotaId = un.QuotaId;
                    unpricing.UnpricingId = un.Id;
                    unpricing.RelUnpricingId = newUn.Id;
                    unpricing.IsAutoGenerated = true;
                    unpricingService.DeferPricing(unpricing, CurrentUser.Id);
                }
            }
        }
Esempio n. 3
0
     private void FixupBaseUnpricing(Unpricing previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.RelatedUnpricings.Contains(this))
         {
             previousValue.RelatedUnpricings.Remove(this);
         }
 
         if (BaseUnpricing != null)
         {
             if (!BaseUnpricing.RelatedUnpricings.Contains(this))
             {
                 BaseUnpricing.RelatedUnpricings.Add(this);
             }
 
             RelUnpricingId = BaseUnpricing.Id;
         }
         else if (!skipKeys)
         {
             RelUnpricingId = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("BaseUnpricing")
                 && (ChangeTracker.OriginalValues["BaseUnpricing"] == BaseUnpricing))
             {
                 ChangeTracker.OriginalValues.Remove("BaseUnpricing");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("BaseUnpricing", previousValue);
             }
             if (BaseUnpricing != null && !BaseUnpricing.ChangeTracker.ChangeTrackingEnabled)
             {
                 BaseUnpricing.StartTracking();
             }
         }
     }
Esempio n. 4
0
     private void FixupParentUnpricing(Unpricing previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.ChildUnpricings.Contains(this))
         {
             previousValue.ChildUnpricings.Remove(this);
         }
 
         if (ParentUnpricing != null)
         {
             if (!ParentUnpricing.ChildUnpricings.Contains(this))
             {
                 ParentUnpricing.ChildUnpricings.Add(this);
             }
 
             UnpricingId = ParentUnpricing.Id;
         }
         else if (!skipKeys)
         {
             UnpricingId = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("ParentUnpricing")
                 && (ChangeTracker.OriginalValues["ParentUnpricing"] == ParentUnpricing))
             {
                 ChangeTracker.OriginalValues.Remove("ParentUnpricing");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("ParentUnpricing", previousValue);
             }
             if (ParentUnpricing != null && !ParentUnpricing.ChangeTracker.ChangeTrackingEnabled)
             {
                 ParentUnpricing.StartTracking();
             }
         }
     }