public int CreateOrder(Order order) { var dataRec = Mapper.Map <Data.Models.Order>(order); using (var ts = new TransactionScope()) { int id = _orderGateway.Insert(dataRec); var gios = Mapper.Map <ICollection <Data.Models.GoodsInOrder> >(order.GoodsInOrder); foreach (var goodsInOrder in gios) { goodsInOrder.OrderId = id; _goodsInOrderGateway.Insert(goodsInOrder); } ts.Complete(); return(id); } }