public IActionResult Delete(int id) { var orderItem = _orderItemService.GetById(id); _orderItemService.Delete(id); return(RedirectToAction("Details", "Order", new { Id = orderItem.OrderId })); }
public ActionResult <OrderItem> DeleteOrderItem(int id) { var orderitem = _orderItemService.GetOrderItemById(id); if (orderitem == null) { return(NotFound()); } _orderItemService.Delete(orderitem); return(orderitem); }
public IActionResult Delete(int id) { try { _orderItemService.Delete(id); return(NoContent()); } catch (Exception) { return(NotFound()); } }
public ActionResult Delete(Guid id) { var orders = orderItemService.GetMany(d => d.OrderId == id); foreach (var item in orders) { orderItemService.Delete(item); } orderService.Delete(id); return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { var order = _orderService.GetById(id); _orderService.Delete(order); var orderItems = _orderItemService.GetOrderItemsByOrderId(order.OrderId); foreach (var item in orderItems) { _orderItemService.Delete(item); } return(RedirectToAction(nameof(Index))); }
public async Task <BaseResult> CreateOrUpdate(OrderModel model, int updateBy = 0, string updateByUserName = "") { var ward = _wardService.Get(model.WardId); model.Address = ward.Name + ward.District.Name + ward.District.City.Name; List <OrderItemModel> order_Items = null; if (model.ListOrderItem != null) { order_Items = model.ListOrderItem; model.ListOrderItem = null; } var order = model.ToOrder(); if (order.Id > 0) { if (order_Items != null) { List <int> listInDTB = _orderItemService.GetOrderItemByOrderId(model.Id).ToList(); List <int> orderItemUpdateID = new List <int> { }; foreach (OrderItemModel orderItemModel2 in order_Items) { await _orderItemService.CreateOrUpdate(orderItemModel2); orderItemUpdateID.Add(orderItemModel2.Id); } foreach (int a in listInDTB) { if (!orderItemUpdateID.Contains(a)) { await _orderItemService.Delete(a); } } order_Items = null; } //Cập nhật return(await Update(order)); } else { order.CreatedTime = DateTime.Now; CreateOrUpdateResultInt rs = await Create(order); if (order_Items != null) { foreach (OrderItemModel orderItemModel2 in order_Items) { orderItemModel2.OrderId = rs.Id; await _orderItemService.CreateOrUpdate(orderItemModel2); } } return(rs); } }
public IActionResult Delete(int id) { orderItemService.Delete(id); return(NoContent()); }
public async Task <ActionResult> Delete(Guid id) { return(await IOrderItemService.Delete(id)); }
public IActionResult Delete(int id) { _orderItemService.Delete(id); return(StatusCode(StatusCodes.Status200OK, "Succesufuly deleted order!")); }
public async Task <IActionResult> Delete(int id) { var result = await _Service.Delete(id); return(Ok(result)); }
public IActionResult Delete(int id) { _orderItemService.Delete(id); return(StatusCode((int)HttpStatusCode.NoContent)); }
public IActionResult DeleteOrderItem(int id) { _orderItemService.Delete(id); return(Ok("delete success")); }
public IActionResult DeleteConfirmed(int id) { _orderItemService.Delete(id); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(int id) { var response = await _service.Delete(id); return(StatusCode(response.Code, response)); }