public JsonResult DeleteCoupons(int couponId)
        {
            var user     = _userService.GetUserByEmail(User.Identity.Name);
            var response = _couponService.DeleteCoupon(couponId, user.Id);

            return(new JsonResult
            {
                ContentType = "application/json",
                Data = response
            });
        }
Exemple #2
0
 public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
 {
     return(await Task.Run(() =>
     {
         var coupon = _couponService.GetCouponByProductId(request.ProductId);
         _couponService.DeleteCoupon(coupon);
         return new DeleteDiscountResponse {
             Success = true
         };
     }));
 }
 public async Task <IActionResult> Delete(int id)
 {
     if (id == 0)
     {
         return(NotFound());
     }
     if (await couponService.DeleteCoupon(id))
     {
         return(RedirectToAction(nameof(Index)));
     }
     return(View());
 }
Exemple #4
0
        public async Task <ActionResult> Delete(int id)
        {
            string message;

            try
            {
                // TODO: Add delete logic here
                await _service.DeleteCoupon(id);

                message = "Success";
            }
            catch (Exception ex)
            {
                message = ex.Message.ToString();
            }
            return(RedirectToAction("Index"));
        }