public void EditOrderRegel(OrderRegel orderRegel) { bool newProduct = true; foreach (OrderRegel regel in GetOrderRegels()) { if (regel.product.id == orderRegel.product.id) { newProduct = false; } } DtoOrderRegel DTO = orderRegel.ToDTO(); IDalOrder orderDAL = DalFactory.CreateOrderDal(); if (newProduct && orderRegel.aantal > 0) { orderDAL.AddOrderRegel(id, DTO); } else if (!newProduct && orderRegel.aantal > 0) { orderDAL.UpdateOrderRegel(id, DTO); } else if (!newProduct && orderRegel.aantal == 0) { orderDAL.DeleteOrderRegel(id, DTO); } }
public List <OrderRegel> GetOrderRegels() { IDalOrder orderDAL = DalFactory.CreateOrderDal(); List <DtoOrderRegel> DTOs = orderDAL.GetOrderRegels(id); List <OrderRegel> orderRegels = new List <OrderRegel>(); ProductContainer productContainer = new ProductContainer(); foreach (DtoOrderRegel DTO in DTOs) { int aantal = DTO.Aantal; Product product = productContainer.GetByID(DTO.ProductId); OrderRegel orderRegel = new OrderRegel(aantal, product); orderRegels.Add(orderRegel); } return(orderRegels); }