//Cập nhật Brand public async Task <bool> Update(LineDto model) { var Line = _mapper.Map <Line>(model); _repoLine.Update(Line); return(await _repoLine.SaveAll()); }
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); }