Пример #1
0
        public void Update(OrderInput orderInput)
        {
            var order           = _orderRepository.Get(orderInput.Id);
            var lines           = _lineRepository.GetByOrder(orderInput.Id);
            var businessPartner = new BusinessPartner(orderInput.CardCode, orderInput.CardName);

            var linesInputToAdd    = orderInput.Lines.Where(c => !lines.Any(x => x.Id.ToString().Equals(c.Id))).ToList();
            var linesInputToUpdate = orderInput.Lines.Where(c => lines.Any(x => x.Id.ToString().Equals(c.Id))).ToList();
            var linesToRemove      = lines.Where(c => !orderInput.Lines.Any(x => x.Id.Equals(x.Id.ToString()))).ToList();

            var linesToAdd    = CreateLine(linesInputToAdd);
            var linesToUpdate = CreateLine(linesInputToUpdate);

            linesToUpdate.ForEach(l => l.Update(l));
            order.AddLine(linesToAdd);
            order.RemoveLine(linesToRemove);

            order.Update(businessPartner);
            _lineRepository.Update(linesToUpdate);
            _lineRepository.Add(linesToAdd);
            _lineRepository.Delete(linesToRemove);
            _orderRepository.Update(order);
        }
Пример #2
0
 public void DeleteLine(int id)
 {
     _lineRepository.Delete(id);
 }