public void SaveAgreement(Agreement newAgreement) { SetTempOrderAgreemenr(newAgreement); _agreementRepository.Add(newAgreement); if (tempOrderAgreement != null) { tempOrderAgreement.AgreementId = newAgreement.Id; if (_orderAgreementRepository.GetAllByExpression().Where(ordAgr => ordAgr.OrderId == tempOrderAgreement.OrderId).ToList() == null) { _orderAgreementRepository.Add(tempOrderAgreement); } } }
public void UpdateOrder(Order newOrder) { var tempOrderAgreement = newOrder.OrderAgreement; newOrder.OrderAgreement = null; _orderRepository.Update(newOrder); if (tempOrderAgreement != null && _orderAgreementRepository.GetAllByExpression() .FirstOrDefault(ordAgr => ordAgr.OrderId == tempOrderAgreement.OrderId) == null) { _orderAgreementRepository.Add(tempOrderAgreement); } }