public IActionResult AddCoupon(CouponDetails coupon)
 {
     try
     {
         couponRepository.AddCoupon(coupon);
         return(Ok());
     }
     catch (Exception e)
     {
         return(NotFound(e.Message));
     }
 }
Exemple #2
0
        public async Task <IActionResult> AddCoupon(CouponAddDto coupon)
        {
            if (coupon.ProductIDs == null)
            {
                coupon.ProductIDs = "";
            }
            var couponEntity = mapper.Map <Coupon>(coupon);

            couponRepository.AddCoupon(couponEntity);
            await couponRepository.SaveAsync();

            var dtoToReturn = mapper.Map <CouponDto>(couponEntity);

            return(CreatedAtRoute(nameof(GetCoupon),
                                  new { couponID = couponEntity.Id },
                                  dtoToReturn));
        }
        public void AddCoupon()
        {
            Coupon coupon = new Coupon
            {
                CouponCode         = "Test12324",
                CouponComment      = "Test",
                IsEnable           = true,
                DiscountTypeID     = 1,
                DiscountAmount     = 00,
                ActiveFromDate     = System.DateTime.Now,
                ActiveTillDate     = System.DateTime.Now,
                SubtotalRangeBegin = 00,
                SubtotalRangeEnd   = 0,
                NumberOfUsers      = 0
            };
            var _id = _couponRepository.AddCoupon(coupon);

            Assert.True(_id > 0, "failed");
        }
        public async Task <bool> AddCoupon(CouponDetails coupon)
        {
            try
            {
                bool result = await _iCoupounRepositoty.AddCoupon(coupon);

                if (result == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #5
0
        /// <summary>
        /// adding coupon
        /// </summary>
        /// <param name="coupon"></param>
        /// <returns></returns>
        public async Task <bool> AddCoupon(CouponDetails coupon)
        {
            log.Info("In CouponManagementHelper :   AddCoupon(CouponDetails coupon)");
            try
            {
                bool result = await _iCoupounRepositoty.AddCoupon(coupon);

                if (result == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                log.Error("Exception CouponManagementHelper:  AddCoupon(CouponDetails coupon)" + e.Message);
                throw;
            }
        }
 public int AddCoupon(Coupon couponInfo)
 {
     return(_couponRepository.AddCoupon(couponInfo));
 }
        public ActionResult AddCoupon(Coupon coupon)
        {
            int _couponID = _couponRepository.AddCoupon(_mapper.Map <OnlineStore.Core.Data.Model.Coupon>(coupon));

            return(_couponID == 0 ? NotFound(_couponID) : (ActionResult)Ok(_couponID));
        }
 public void AddCoupon(Order order)
 {
     _couponRepository.AddCoupon(order);
 }