Ejemplo n.º 1
0
        public async Task <IActionResult> PutCouponItem(long id, CouponItem CouponItem)
        {
            if (id != CouponItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(CouponItem).State = EntityState.Modified;

            try
            {
                SetWinningCoupon(CouponItem);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CouponItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCoupon(int id, Coupon coupon)
        {
            HttpContext.VerifyUserHasAnyAcceptedScope(new string[] { "Coupon.ReadWrite", "Coupon.FullControl" });

            if (id != coupon.Id)
            {
                return(BadRequest());
            }

            _context.Entry(coupon).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CouponExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCouponCode(int id, CouponCode couponCode)
        {
            if (id != couponCode.Id)
            {
                return(BadRequest());
            }

            _context.Entry(couponCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CouponCodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }