private void Save() { var model = new OrderDetailDTO(); model.SupplierId = SelectedSupplier.Id; model.LocationId = this.locationId; model.OrderDate = DateTime.Now; model.AcceptDate = DateTime.Now; model.Accept = false; model.Products = Products.Where(x => !x.Value.Equals(0)).Select(x => new ProductOrderedDTO() { ProductId = x.ProductId, Value = x.Value, Price = x.Price, Tax = x.Tax }).ToList(); orderApi = new OrderAPI(); var resultFlag = orderApi.Create(model); if (resultFlag) { MessageBox.Show("Заказ создан"); } if (!resultFlag) { MessageBox.Show("Ошибка создания заказа"); } }