public void DeleteCoupon(int couponId)
        {
            CouponDetails couponDetails = couponManagementContext.CouponDetails.Find(couponId);

            couponManagementContext.Remove(couponDetails);
            couponManagementContext.SaveChanges();
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="couponId"></param>
        /// <returns></returns>
        public async Task <bool> DeleteCoupon(int couponId)
        {
            try
            {
                CouponDetails couponDetails = _couponManagementContext.CouponDetails.Find(couponId);
                _couponManagementContext.Remove(couponDetails);
                int result = await _couponManagementContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// For deleting coupon based on couponid
        /// </summary>
        /// <param name="couponId"></param>
        /// <returns></returns>
        public async Task <bool> DeleteCoupon(int couponId)
        {
            log.Info("In CouponRepository :   DeleteCoupon(int couponId)");
            try
            {
                CouponDetails coupon = _couponManagementContext.CouponDetails.Find(couponId);
                _couponManagementContext.Remove(coupon);
                int result = await _couponManagementContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                log.Error("Exception CouponRepository:  DeleteCoupon(int couponId)" + e.Message);
                throw;
            }
        }