コード例 #1
0
 public IActionResult DeleteOrder(Orders order)
 {
     try
     {
         orderServices.DeleteOrder(order);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
コード例 #2
0
        public async Task <IActionResult> Edit(string foodId)
        {
            AppIdentityUser user = await _userManager.GetUserAsync(User);

            Food food = await _foodServices.GetFood(foodId);

            if (user != null && food != null)
            {
                OrderDetail order = await _orderServices.GetOrderToday(user.Id);

                if (order != null)
                {
                    if (order.FoodId != foodId)
                    {
                        if (await _orderServices.DeleteOrder(order) && await _orderServices.CreateOrder(food: food, user: user))
                        {
                            ViewBag.foodName = food.Name;
                            return(View("~/Views/Order/EditSuccess.cshtml"));
                        }
                    }
                }
            }
            return(RedirectToAction(actionName: "Index", controllerName: "Home"));
        }
コード例 #3
0
        public async Task <IActionResult> DeleteOrder(int orderId)
        {
            try
            {
                var result = await _orderServices.DeleteOrder(orderId);

                if (result == 0)
                {
                    return(new BadRequestObjectResult(new { Message = "Không tìm thấy mã đơn hàng. Vui lòng thử lại" }));
                }
                return(Ok(new { Message = "Xóa đơn hàng thành công!" }));
            }
            catch (Exception ex)
            {
                return(new BadRequestObjectResult(new { Message = ex.Message.ToString() }));
            }
        }
コード例 #4
0
 //Delete order
 public IActionResult RemoveOrders(int id)
 {
     orderService.DeleteOrder(id);
     return(RedirectToAction("GetAllOrders", "Order"));
 }