AngelikaSuhareva 4 months ago
parent
commit
cdd56c8c89
3 changed files with 49 additions and 16 deletions
  1. 23 15
      ViewModels/MainWindowViewModel.cs
  2. 25 0
      ViewModels/OutletsListViewModel.cs
  3. 1 1
      Views/OutletsView.axaml

+ 23 - 15
ViewModels/MainWindowViewModel.cs

@@ -26,6 +26,11 @@ namespace Acosta.ViewModels
         AddOutletsViewModel outletVM = new AddOutletsViewModel(myConnection);
         public AddOutletsViewModel OutletVM { get => outletVM; set => outletVM = value; }
 
+
+        OutletsListViewModel outletListVM = new OutletsListViewModel(myConnection);
+        public OutletsListViewModel OutletListVM { get => outletListVM; set => outletListVM = value; }
+
+
         PersonalAccountViewModel personalAccountVM = new PersonalAccountViewModel(myConnection);
         public PersonalAccountViewModel PersonalAccountVM { get => personalAccountVM; set => personalAccountVM = value; }
 
@@ -75,24 +80,25 @@ namespace Acosta.ViewModels
         public List<Project> ListProjects => myConnection.Projects.ToList();
         public List<Employee> ListEmployees => myConnection.Employees.ToList();
         public List<Outlet> ListOutlets => myConnection.Outlets.ToList();
-        List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));
+        //public List<string> fkTrade => myConnection.TradeNetworks.ToList().Select(x => x.Title).Where()
+        //List<a> newList = new List<a>(new a((from p in myConnection.Outlets.ToList() select p.Outletid).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Address).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.Outlets.ToList() select p.Location).ToImmutableList().ToList().FirstOrDefault(), (from p in myConnection.TradeNetworks.ToList() select p.Title).ToImmutableList().ToList().FirstOrDefault()));
         
-        public struct a
-        {
-            int Outlerid;
-            string Address;
-            string Location;
-            string TradeNetworks;
+        //public struct a
+        //{
+        //    int Outlerid;
+        //    string Address;
+        //    string Location;
+        //    string TradeNetworks;
             
 
-            public a(int oid, string ad, string loc, string tn)
-            {
-                Outlerid = oid;
-                Address = ad;
-                Location = loc;
-                TradeNetworks = tn;
-            }
-        }
+        //    public a(int oid, string ad, string loc, string tn)
+        //    {
+        //        Outlerid = oid;
+        //        Address = ad;
+        //        Location = loc;
+        //        TradeNetworks = tn;
+        //    }
+        //}
         //public IEnumerable<dynamic> ListOutlets => myConnection.Outlets.Select(p => new
         //{
         //    p.Outletid,
@@ -119,6 +125,8 @@ namespace Acosta.ViewModels
 
         
 
+
+
         /*public List<Role> rolesList => (from p in myConnection.Roles.ToList() where p.Title != "Оператор" select p).ToImmutableList().ToList();
         public List<Employee> userList => (from p in myConnection.Employees.ToList() where p.Role != 1 select p).ToImmutableList().ToList();*/
 

+ 25 - 0
ViewModels/OutletsListViewModel.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Acosta.Models;
+using Microsoft.EntityFrameworkCore;
+using ReactiveUI;
+
+namespace Acosta.ViewModels
+{
+	public class OutletsListViewModel : ReactiveObject
+	{
+        SuharevaContext myConnection;
+        Outlet? currentOutlet;
+
+        public OutletsListViewModel(SuharevaContext myConnection)
+        {
+            this.myConnection = myConnection;
+            CurrentOutlet = myConnection.Outlets.Include(x => x.TradeNetworksNavigation).FirstOrDefault();
+        }
+
+        public List<TradeNetwork> ListTrades => myConnection.TradeNetworks.ToList();
+
+        public Outlet? CurrentOutlet { get => currentOutlet; set => currentOutlet = value; }
+    }
+}

+ 1 - 1
Views/OutletsView.axaml

@@ -197,7 +197,7 @@
 						<TextBlock Classes="Data">Типа ID</TextBlock>
 					</Border>-->
 								<TextBlock Text="{Binding Outletid}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа id</TextBlock>
-								<TextBlock Text="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).getTitle}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа название торговой сети</TextBlock>
+								<TextBlock Text="{Binding TradeNetworksNavigation.Title}" Classes="EditTextBox" Width="70" Margin="0 0 140 0">Типа название торговой сети</TextBlock>
 								<!--<Border  Classes="Data" CornerRadius="13"  Width="310" Height="40" Margin="0 0 140 0">
 						<TextBlock Classes="Data">Типа название торговой сети</TextBlock>
 					</Border>-->