public TransactionStatusModel AddTransaction(TransactionDTO transaction) { TransactionStatusModel transStatus = new TransactionStatusModel(); ProjectDataService dataService = new ProjectDataService(); using (TransactionScope tran = new TransactionScope()) { try { transStatus = dataService.AddTransaction(transaction); } catch (Exception ex) { transStatus.ReturnStatus = false; transStatus.ReturnMessage.Add("Add Transaction Failed"); return(transStatus); } try { foreach (var sale in transaction.SaleDtoList) { transStatus = dataService.AddSale(sale); transStatus = dataService.UpdateStock(sale.ProductDto); //comment out this line when using Sale Generator } } catch (Exception ex) { transStatus.ReturnStatus = false; transStatus.ReturnMessage.Add("Add Sale Failed"); return(transStatus); } tran.Complete(); } return(transStatus); }