瀏覽代碼

Реализован выбор пункта доставки

MeseryGG 7 月之前
父節點
當前提交
586eb5b1ce

+ 16 - 0
OOO_WriteAndClear/DBModels/PickupPointPartialClass.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OOO_WriteAndClear.DBModels
+{
+    public partial class PickupPoint
+    {
+        public override string ToString()
+        {
+            return "№" + PickupPointId + " " + PickupPointAdress;
+        }
+    }
+}

+ 4 - 0
OOO_WriteAndClear/MVP/MVPInterfaces/IOrderCartWindowContract.cs

@@ -29,6 +29,8 @@ namespace OOO_WriteAndClear.MVP.MVPInterfaces
 
             void RemoveProductFromOrder(string productArticle);
 
+            ICollection<PickupPoint> GetAllPickupPoints();
+
             void AddOrderInSystem();
         }
 
@@ -43,6 +45,8 @@ namespace OOO_WriteAndClear.MVP.MVPInterfaces
 
             void RemoveProductFromOrder(string productArticle);
 
+            ICollection<PickupPoint> GetAllPickupPoints();
+
             void AddOrderInSystem();
         }
     }

+ 8 - 0
OOO_WriteAndClear/MVP/Models/OrderCartWindowModel.cs

@@ -42,6 +42,14 @@ namespace OOO_WriteAndClear.MVP.Models
             OrderFormerer.RemoveProductUnitFromOrder(product);
         }
 
+        public ICollection<PickupPoint> GetAllPickupPoints()
+        {
+            using (VorobiewTradeContext db = new VorobiewTradeContext())
+            {
+                return db.PickupPoints.ToList();
+            };
+        }
+
         public void AddOrderInSystem()
         {
         }

+ 3 - 0
OOO_WriteAndClear/MVP/Presenters/OrderCartWindowPresenter.cs

@@ -50,6 +50,9 @@ namespace OOO_WriteAndClear.MVP.Presenters
             _model.AddOrderInSystem();
         }
 
+        public ICollection<PickupPoint> GetAllPickupPoints() => 
+            _model.GetAllPickupPoints();
+
         #endregion
 
 

+ 7 - 0
OOO_WriteAndClear/MVP/Views/OrderCartWindow.xaml

@@ -155,6 +155,13 @@
 
                     </GroupBox>
 
+                    <GroupBox Margin="0 10 0 0"
+                              Header="Пункт выдачи">
+
+                        <ComboBox x:Name="PickupPointComboBox"/>
+
+                    </GroupBox>
+
                     <Button Height="30" 
                             Margin="0 10 0 0"
                             Content="Формирование заказа"

+ 15 - 0
OOO_WriteAndClear/MVP/Views/OrderCartWindow.xaml.cs

@@ -28,6 +28,7 @@ namespace OOO_WriteAndClear.MVP.Views
         {
             _presenter = new OrderCartWindowPresenter(this);
             InitializeComponent();
+            LoadPickupPoints();
         }
 
 
@@ -36,6 +37,7 @@ namespace OOO_WriteAndClear.MVP.Views
             _presenter = new OrderCartWindowPresenter(this);
             InitializeComponent();
             SetCurrentOrderFormerer(orderFormerer);
+            LoadPickupPoints();
         }
 
 
@@ -159,5 +161,18 @@ namespace OOO_WriteAndClear.MVP.Views
 
         private void SetCurrentOrderFormerer(OrderFormerer orderFormerer)
             => _presenter.SetCurrentOrderFormerer(orderFormerer);
+
+        private void LoadPickupPoints()
+        {
+            ICollection<PickupPoint> pickupPoints;
+            Task.Run(() =>
+            {
+                pickupPoints = _presenter.GetAllPickupPoints();
+                Dispatcher.BeginInvoke(new Action(() =>
+                {
+                    PickupPointComboBox.ItemsSource = pickupPoints;
+                }));
+            });
+        }
     }
 }