Exemplo n.º 1
0
        public string UpdateOrDeleteCoupon(UniqueCoupon model, string actionType)
        {
            if (actionType.Equals("update", StringComparison.Ordinal))
            {
                var updated = false;
                var coupon  = _couponService.GetById(model.Id);

                if (coupon != null)
                {
                    coupon.Code            = model.Code;
                    coupon.Expiration      = model.Expiration;
                    coupon.MaxRedemptions  = model.MaxRedemptions;
                    coupon.UsedRedemptions = model.UsedRedemptions;
                    coupon.ValidFrom       = model.ValidFrom;
                    updated = _couponService.SaveCoupons(new List <UniqueCoupon> {
                        coupon
                    });
                }

                return(updated ? "update_ok" : "update_nok");
            }
            else
            {
                var deleted = _couponService.DeleteById(model.Id);
                return(deleted ? "delete_ok" : "delete_nok");
            }
        }
Exemplo n.º 2
0
        public ActionResult UpdateCoupon(UniqueCoupon model)
        {
            var coupon = _couponService.GetById(model.Id);

            if (coupon != null)
            {
                coupon.Code            = model.Code;
                coupon.Expiration      = model.Expiration;
                coupon.MaxRedemptions  = model.MaxRedemptions;
                coupon.UsedRedemptions = model.UsedRedemptions;
                coupon.Valid           = model.Valid;
                _couponService.SaveCoupons(new List <UniqueCoupon> {
                    coupon
                });
            }

            return(new ContentResult
            {
                Content = model.PromotionId.ToString()
            });
        }