コード例 #1
0
        public virtual async Task <CouponDto> OccupyAsync(Guid id, OccupyCouponInput input)
        {
            var coupon = await GetEntityByIdAsync(id);

            if (coupon.UserId != CurrentUser.GetId())
            {
                throw new AbpAuthorizationException();
            }

            if (coupon.OrderId.HasValue)
            {
                throw new CouponHasBeenOccupiedException();
            }

            var couponTemplate = await _couponTemplateRepository.GetAsync(coupon.CouponTemplateId);

            coupon.SetOrderId(input.OrderId);

            await _repository.UpdateAsync(coupon, true);

            return(FillCouponTemplateData(await MapToGetOutputDtoAsync(coupon), couponTemplate));
        }
コード例 #2
0
 public Task <CouponDto> OccupyAsync(Guid id, OccupyCouponInput input)
 {
     return(_service.OccupyAsync(id, input));
 }