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); }
public void ShouldUpdateOrderDetails() { var order = new Order { Name = "NewName", Address = "NewAddress", Shipped = true, }; _orderRepo.AddRange(new List <Order> { order }); order.Name = "NewNewName"; _orderRepo.Update(order, false); var item = _orderRepo.Find(order.Id); var count = _orderRepo.SaveChanges(); Assert.Equal(1, count); Assert.Equal("NewNewName", item.Name); Assert.Equal("NewAddress", item.Address); }
public Order Find(int id) { return(_orderRepo.Find(id)); }