diff --git a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs index 0dbe30a..7d4b062 100644 --- a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs @@ -41,14 +41,9 @@ namespace SushiBarFileImplement.Implements private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; - foreach (var sushi in source.ListSushi) - { - if (sushi.Id == order.SushiId) - { - viewModel.SushiName = sushi.SushiName; - break; - } - } + var sushi = source.ListSushi.FirstOrDefault(x => x.Id == order.SushiId); + if (sushi == null) return null; + viewModel.SushiName = sushi.SushiName; return viewModel; } public OrderViewModel? Insert(OrderBindingModel model)