Exemplo n.º 1
0
 private void EnableCoupon(Guid id, bool enabled)
 {
     using (var dc = CreateContext())
     {
         var entity = new ProductCouponEntity {
             id = id, enabled = !enabled
         };
         dc.ProductCouponEntities.Attach(entity);
         entity.enabled = enabled;
         dc.SubmitChanges();
     }
 }
Exemplo n.º 2
0
 public static Coupon Map(this ProductCouponEntity entity)
 {
     return(new Coupon
     {
         Id = entity.id,
         Code = entity.code,
         Discount = entity.percentageDiscount != null
             ? (CouponDiscount) new PercentageCouponDiscount {
             Percentage = entity.percentageDiscount.Value
         }
             : entity.fixedDiscount != null
                 ? new FixedCouponDiscount {
             Amount = entity.fixedDiscount ?? 0
         }
                 : null,
         IsEnabled = entity.enabled,
         ExpiryDate = entity.expiryDate,
         CanBeUsedOnce = entity.canBeUsedOnce,
         ProductIds = entity.ProductCouponProductEntities.Map(),
         RedeemerIds = entity.ProductCouponRedeemerEntities.Map(),
     });
 }