Exemplo n.º 1
0
        // GET: OrderController/Delete/5
        public ActionResult Delete(int id)
        {
            var order = _repo.FindById(id);

            if (order == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(order);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
 [ProducesResponseType(500)] //Returned when there was an error in the repo
 public IActionResult DeleteOrder(long id)
 {
     _repo.Delete(new Order {
         Id = id
     });
     return(NoContent());
 }
Exemplo n.º 3
0
 public IActionResult Delete(Order order)
 {
     if (order != null)
     {
         orderRepo.Delete(order);
     }
     return(RedirectToAction("OrdersManagment"));
 }
Exemplo n.º 4
0
        public IActionResult delete(order o)
        {
            if (o != null)
            {
                orderRepo.Delete(o);
                return(NoContent());
            }

            return(BadRequest());
        }
        public void ShouldDeleteAnOrder()
        {
            var item = _orderRepo.Find(1);

            _orderRepo.Context.Entry(item).State = EntityState.Detached;
            _orderRepo.Delete(item);
            Context.OrderId = 1;
            var order = _orderRepo.Find(Context.OrderId);

            Assert.Null(order);
        }
Exemplo n.º 6
0
        public ActionResult Delete(int?i)
        {
            if (Session["UserID"] != null && Session["UserType"].ToString().ToLower() == "chef")
            {
                if (i != null)
                {
                    oRepo.Delete((int)i);
                }
                return(RedirectToAction("Index", "Order"));
            }

            return(RedirectToAction("Login", "Home", new { area = "" }));
        }
Exemplo n.º 7
0
        public void Delete(int OrderID)
        {
            if (OrderID < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(OrderID));
            }
            var order = _orderRepo.Find(OrderID);

            _orderRepo.Delete(order);
            var orderDetail = _order_DetailsRepo.Where(x => x.OrderID == OrderID);

            _order_DetailsRepo.RemoveRange(orderDetail);
        }
Exemplo n.º 8
0
        public HttpResponseMessage DeleteOrder(int orderId)
        {
            bool result = orderRepo.Delete(orderId);

            return(CheckResult(result));
        }
Exemplo n.º 9
0
 public void Remove(int id)
 {
     _orderRepo.Delete(id);
     _orderRepo.SaveChanges();
 }