diff --git a/.idea/.idea.demo-12-14/.idea/encodings.xml b/.idea/.idea.demo-12-14/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.demo-12-14/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.demo-12-14/.idea/indexLayout.xml b/.idea/.idea.demo-12-14/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.demo-12-14/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.demo-12-14/.idea/projectSettingsUpdater.xml b/.idea/.idea.demo-12-14/.idea/projectSettingsUpdater.xml
new file mode 100644
index 0000000..64af657
--- /dev/null
+++ b/.idea/.idea.demo-12-14/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.demo-12-14/.idea/vcs.xml b/.idea/.idea.demo-12-14/.idea/vcs.xml
new file mode 100644
index 0000000..d843f34
--- /dev/null
+++ b/.idea/.idea.demo-12-14/.idea/vcs.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.demo-12-14/.idea/workspace.xml b/.idea/.idea.demo-12-14/.idea/workspace.xml
new file mode 100644
index 0000000..3c6be61
--- /dev/null
+++ b/.idea/.idea.demo-12-14/.idea/workspace.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1734177075418
+
+
+ 1734177075418
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo-12-14.sln b/demo-12-14.sln
new file mode 100644
index 0000000..37a0537
--- /dev/null
+++ b/demo-12-14.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35222.181
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo-12-14", "demo-12-14\demo-12-14.csproj", "{85150DA8-82FE-41D9-B1EE-915B1231DE5F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {85150DA8-82FE-41D9-B1EE-915B1231DE5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {85150DA8-82FE-41D9-B1EE-915B1231DE5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {85150DA8-82FE-41D9-B1EE-915B1231DE5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {85150DA8-82FE-41D9-B1EE-915B1231DE5F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5344D68D-4280-42B8-9639-32A65BE8879F}
+ EndGlobalSection
+EndGlobal
diff --git a/demo-12-14/App.axaml b/demo-12-14/App.axaml
new file mode 100644
index 0000000..8c2eba8
--- /dev/null
+++ b/demo-12-14/App.axaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo-12-14/App.axaml.cs b/demo-12-14/App.axaml.cs
new file mode 100644
index 0000000..2a9d8a7
--- /dev/null
+++ b/demo-12-14/App.axaml.cs
@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+
+namespace demo
+{
+ public partial class App : Application
+ {
+ public override void Initialize()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ public override void OnFrameworkInitializationCompleted()
+ {
+ if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ desktop.MainWindow = new MainWindow();
+ }
+
+ base.OnFrameworkInitializationCompleted();
+ }
+ }
+}
\ No newline at end of file
diff --git a/demo-12-14/MainWindow.axaml b/demo-12-14/MainWindow.axaml
new file mode 100644
index 0000000..cec96dd
--- /dev/null
+++ b/demo-12-14/MainWindow.axaml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+ без сорт.
+
+
+ убыв.
+
+
+ возраст.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo-12-14/MainWindow.axaml.cs b/demo-12-14/MainWindow.axaml.cs
new file mode 100644
index 0000000..b27226f
--- /dev/null
+++ b/demo-12-14/MainWindow.axaml.cs
@@ -0,0 +1,131 @@
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
+using Avalonia.Utilities;
+using demoModels;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+
+namespace demo
+{
+ public partial class MainWindow : Window
+ {
+ ObservableCollection products = new ObservableCollection();
+ List dataSourceProducts;
+ ObservableCollection manufactures;
+ public MainWindow()
+ {
+ InitializeComponent();
+ using var context = new ProductsTradeContext();
+ dataSourceProducts = context.Products.Include(it => it.Manufacturer).Select(product => new ProductPresenter
+ {
+ Id = product.Id,
+ Mainimagepath = product.Mainimagepath,
+ Isactive = product.Isactive,
+ Cost = product.Cost,
+ Title = product.Title,
+ Description = product.Description,
+ Manufacturer = product.Manufacturer,
+ }).ToList();
+ var dataSourceManafacture = context.Manufacturers.Select(it => it.Name).ToList();
+ manufactures = new ObservableCollection(dataSourceManafacture);
+ manufactures.Insert(0," ");
+ ProductBox.ItemsSource = products;
+ ManufactureBox.ItemsSource = manufactures;
+ ManufactureBox.SelectedIndex = 0;
+ DisplayProducts();
+ }
+
+ private void DisplayProducts()
+ {
+ var temp = dataSourceProducts;
+ products.Clear();
+ if (ManufactureBox.SelectedIndex != 0)
+ {
+ temp = temp.Where(it => it.ManufacatureName.Contains(ManufactureBox.SelectedItem.ToString())).ToList();
+ }
+ if (!string.IsNullOrEmpty(SearchBox.Text))
+ {
+ var searchWord = SearchBox.Text.ToLower();
+ temp = temp.Where(it => IsContains(it.Title, it.Description, searchWord)).ToList();
+ }
+ switch (SortBox.SelectedIndex) {
+
+ case 1: temp = temp.OrderBy(temp => temp.Cost).ToList(); break;
+ case 2: temp = temp.OrderByDescending(temp => temp.Cost).ToList(); break;
+ default: break;
+ }
+ foreach (var item in temp)
+ {
+ products.Add(item);
+ }
+ CountTextBlock.Text = $"{temp.Count}\\{dataSourceProducts.Count}";
+
+
+ }
+
+ public bool IsContains(string title, string? description, string searchWord) {
+ string desc = string.Empty;
+ if(description != null) desc = description;
+ string message = (title + desc).ToLower();
+ searchWord = searchWord.ToLower();
+ var result = message.Contains(searchWord);
+ return message.Contains(searchWord);
+ }
+ public void SearchBoxChanging(object sender, TextChangingEventArgs eventArgs)
+ {
+ DisplayProducts();
+ }
+
+ public void SortBox_SelectionChanged(object sender, SelectionChangedEventArgs eventArgs) {
+ DisplayProducts();
+ }
+ public void ManufactureBox_SelectionChanged(object sender, SelectionChangedEventArgs eventArgs)
+ {
+ DisplayProducts();
+ }
+ public void ProductItemClick(object sender, RoutedEventArgs e)
+ {
+ using var context = new ProductsTradeContext();
+ var product = ProductBox.SelectedItem as ProductPresenter;
+ if (product == null) return;
+ var removeProduct = context.Products.Include(it => it.Productsales).First(it => it.Id == product.Id);
+ if(removeProduct == null) return;
+ if(removeProduct.Productsales.Count() > 0) return;
+ context.Products.Remove(removeProduct);
+ if (context.SaveChanges() > 0) products.Remove(product);
+ }
+ public async void AddNewProduct(object sender, RoutedEventArgs e)
+ {
+ using ProductsTradeContext context = new ProductsTradeContext();
+ var newProduct = await new ProductWindow().ShowDialog(this);
+
+ context.Products.Add(newProduct);
+ if (context.SaveChanges() > 0) {
+ newProduct.Manufacturer = context.Manufacturers.Find(newProduct.Manufacturerid);
+ dataSourceProducts.Add(newProduct);
+ }
+ }
+ }
+ public class ProductPresenter() : Product{
+ public string ManufacatureName { get => Manufacturer.Name; }
+ Bitmap? Image { get
+ {
+ try
+ {
+ return new Bitmap(Mainimagepath);
+ }
+ catch
+ {
+ return null;
+ }
+ } }
+ public IBrush Color { get {
+ return Isactive? Brushes.White : Brushes.Gray;
+ } }
+ }
+}
\ No newline at end of file
diff --git a/demo-12-14/Models/Client.cs b/demo-12-14/Models/Client.cs
new file mode 100644
index 0000000..d2ffddd
--- /dev/null
+++ b/demo-12-14/Models/Client.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Client
+{
+ public int Id { get; set; }
+
+ public string Firstname { get; set; } = null!;
+
+ public string Lastname { get; set; } = null!;
+
+ public string? Patronymic { get; set; }
+
+ public DateOnly? Birthday { get; set; }
+
+ public DateTime Registrationdate { get; set; }
+
+ public string? Email { get; set; }
+
+ public string Phone { get; set; } = null!;
+
+ public char Gendercode { get; set; }
+
+ public string? Photopath { get; set; }
+
+ public virtual ICollection Clientservices { get; set; } = new List();
+
+ public virtual Gender GendercodeNavigation { get; set; } = null!;
+
+ public virtual ICollection Tags { get; set; } = new List();
+}
diff --git a/demo-12-14/Models/Clientservice.cs b/demo-12-14/Models/Clientservice.cs
new file mode 100644
index 0000000..93d594f
--- /dev/null
+++ b/demo-12-14/Models/Clientservice.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Clientservice
+{
+ public int Id { get; set; }
+
+ public int Clientid { get; set; }
+
+ public int Serviceid { get; set; }
+
+ public DateTime Starttime { get; set; }
+
+ public string? Comment { get; set; }
+
+ public virtual Client Client { get; set; } = null!;
+
+ public virtual ICollection Documentbyservices { get; set; } = new List();
+
+ public virtual ICollection Productsales { get; set; } = new List();
+
+ public virtual Service Service { get; set; } = null!;
+}
diff --git a/demo-12-14/Models/Documentbyservice.cs b/demo-12-14/Models/Documentbyservice.cs
new file mode 100644
index 0000000..38f2eff
--- /dev/null
+++ b/demo-12-14/Models/Documentbyservice.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Documentbyservice
+{
+ public int Id { get; set; }
+
+ public int Clientserviceid { get; set; }
+
+ public string Documentpath { get; set; } = null!;
+
+ public virtual Clientservice Clientservice { get; set; } = null!;
+}
diff --git a/demo-12-14/Models/Gender.cs b/demo-12-14/Models/Gender.cs
new file mode 100644
index 0000000..7783b58
--- /dev/null
+++ b/demo-12-14/Models/Gender.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Gender
+{
+ public char Code { get; set; }
+
+ public string? Name { get; set; }
+
+ public virtual ICollection Clients { get; set; } = new List();
+}
diff --git a/demo-12-14/Models/Manufacturer.cs b/demo-12-14/Models/Manufacturer.cs
new file mode 100644
index 0000000..1df2e2b
--- /dev/null
+++ b/demo-12-14/Models/Manufacturer.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Manufacturer
+{
+ public int Id { get; set; }
+
+ public string Name { get; set; } = null!;
+
+ public DateOnly? Startdate { get; set; }
+
+ public virtual ICollection Products { get; set; } = new List();
+}
diff --git a/demo-12-14/Models/Product.cs b/demo-12-14/Models/Product.cs
new file mode 100644
index 0000000..885d487
--- /dev/null
+++ b/demo-12-14/Models/Product.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Product
+{
+ public int Id { get; set; }
+
+ public string Title { get; set; } = null!;
+
+ public decimal Cost { get; set; }
+
+ public string? Description { get; set; }
+
+ public string? Mainimagepath { get; set; }
+
+ public bool Isactive { get; set; }
+
+ public int? Manufacturerid { get; set; }
+
+ public virtual Manufacturer? Manufacturer { get; set; }
+
+ public virtual ICollection Productphotos { get; set; } = new List();
+
+ public virtual ICollection Productsales { get; set; } = new List();
+
+ public virtual ICollection Attachedproducts { get; set; } = new List();
+
+ public virtual ICollection Mainproducts { get; set; } = new List();
+}
diff --git a/demo-12-14/Models/Productphoto.cs b/demo-12-14/Models/Productphoto.cs
new file mode 100644
index 0000000..65f5f5e
--- /dev/null
+++ b/demo-12-14/Models/Productphoto.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Productphoto
+{
+ public int Id { get; set; }
+
+ public int Productid { get; set; }
+
+ public string Photopath { get; set; } = null!;
+
+ public virtual Product Product { get; set; } = null!;
+}
diff --git a/demo-12-14/Models/ProductsTradeContext.cs b/demo-12-14/Models/ProductsTradeContext.cs
new file mode 100644
index 0000000..8daa4bd
--- /dev/null
+++ b/demo-12-14/Models/ProductsTradeContext.cs
@@ -0,0 +1,369 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
+
+namespace demoModels;
+
+public partial class ProductsTradeContext : DbContext
+{
+ public ProductsTradeContext()
+ {
+ }
+
+ public ProductsTradeContext(DbContextOptions options)
+ : base(options)
+ {
+ }
+
+ public virtual DbSet Clients { get; set; }
+
+ public virtual DbSet Clientservices { get; set; }
+
+ public virtual DbSet Documentbyservices { get; set; }
+
+ public virtual DbSet Genders { get; set; }
+
+ public virtual DbSet Manufacturers { get; set; }
+
+ public virtual DbSet Products { get; set; }
+
+ public virtual DbSet Productphotos { get; set; }
+
+ public virtual DbSet Productsales { get; set; }
+
+ public virtual DbSet Services { get; set; }
+
+ public virtual DbSet Servicephotos { get; set; }
+
+ public virtual DbSet Tags { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
+ => optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=products_trade;Username=postgres;Password=123");
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("client_pkey");
+
+ entity.ToTable("client");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('client_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Birthday).HasColumnName("birthday");
+ entity.Property(e => e.Email)
+ .HasMaxLength(255)
+ .HasColumnName("email");
+ entity.Property(e => e.Firstname)
+ .HasMaxLength(50)
+ .HasColumnName("firstname");
+ entity.Property(e => e.Gendercode)
+ .HasMaxLength(1)
+ .HasColumnName("gendercode");
+ entity.Property(e => e.Lastname)
+ .HasMaxLength(50)
+ .HasColumnName("lastname");
+ entity.Property(e => e.Patronymic)
+ .HasMaxLength(50)
+ .HasColumnName("patronymic");
+ entity.Property(e => e.Phone)
+ .HasMaxLength(20)
+ .HasColumnName("phone");
+ entity.Property(e => e.Photopath)
+ .HasMaxLength(1000)
+ .HasColumnName("photopath");
+ entity.Property(e => e.Registrationdate)
+ .HasColumnType("timestamp(6) without time zone")
+ .HasColumnName("registrationdate");
+
+ entity.HasOne(d => d.GendercodeNavigation).WithMany(p => p.Clients)
+ .HasForeignKey(d => d.Gendercode)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_client_gender");
+
+ entity.HasMany(d => d.Tags).WithMany(p => p.Clients)
+ .UsingEntity>(
+ "Tagofclient",
+ r => r.HasOne().WithMany()
+ .HasForeignKey("Tagid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_tagofclient_tag"),
+ l => l.HasOne().WithMany()
+ .HasForeignKey("Clientid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_tagofclient_client"),
+ j =>
+ {
+ j.HasKey("Clientid", "Tagid").HasName("tagofclient_pkey");
+ j.ToTable("tagofclient");
+ j.IndexerProperty("Clientid").HasColumnName("clientid");
+ j.IndexerProperty("Tagid").HasColumnName("tagid");
+ });
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("clientservice_pkey");
+
+ entity.ToTable("clientservice");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('clientservice_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Clientid).HasColumnName("clientid");
+ entity.Property(e => e.Comment).HasColumnName("comment");
+ entity.Property(e => e.Serviceid).HasColumnName("serviceid");
+ entity.Property(e => e.Starttime)
+ .HasColumnType("timestamp(6) without time zone")
+ .HasColumnName("starttime");
+
+ entity.HasOne(d => d.Client).WithMany(p => p.Clientservices)
+ .HasForeignKey(d => d.Clientid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_clientservice_client");
+
+ entity.HasOne(d => d.Service).WithMany(p => p.Clientservices)
+ .HasForeignKey(d => d.Serviceid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_clientservice_service");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("documentbyservice_pkey");
+
+ entity.ToTable("documentbyservice");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('documentbyservice_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Clientserviceid).HasColumnName("clientserviceid");
+ entity.Property(e => e.Documentpath)
+ .HasMaxLength(1000)
+ .HasColumnName("documentpath");
+
+ entity.HasOne(d => d.Clientservice).WithMany(p => p.Documentbyservices)
+ .HasForeignKey(d => d.Clientserviceid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_documentbyservice_clientservice");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Code).HasName("gender_pkey");
+
+ entity.ToTable("gender");
+
+ entity.Property(e => e.Code)
+ .HasMaxLength(1)
+ .ValueGeneratedNever()
+ .HasColumnName("code");
+ entity.Property(e => e.Name)
+ .HasMaxLength(10)
+ .HasColumnName("name");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("manufacturer_pkey");
+
+ entity.ToTable("manufacturer");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('manufacturer_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Name)
+ .HasMaxLength(100)
+ .HasColumnName("name");
+ entity.Property(e => e.Startdate).HasColumnName("startdate");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("product_pkey");
+
+ entity.ToTable("product");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('product_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Cost)
+ .HasPrecision(19, 4)
+ .HasColumnName("cost");
+ entity.Property(e => e.Description).HasColumnName("description");
+ entity.Property(e => e.Isactive).HasColumnName("isactive");
+ entity.Property(e => e.Mainimagepath)
+ .HasMaxLength(1000)
+ .HasColumnName("mainimagepath");
+ entity.Property(e => e.Manufacturerid).HasColumnName("manufacturerid");
+ entity.Property(e => e.Title)
+ .HasMaxLength(100)
+ .HasColumnName("title");
+
+ entity.HasOne(d => d.Manufacturer).WithMany(p => p.Products)
+ .HasForeignKey(d => d.Manufacturerid)
+ .HasConstraintName("fk_product_manufacturer");
+
+ entity.HasMany(d => d.Attachedproducts).WithMany(p => p.Mainproducts)
+ .UsingEntity>(
+ "Attachedproduct",
+ r => r.HasOne().WithMany()
+ .HasForeignKey("Attachedproductid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_attachedproduct_product1"),
+ l => l.HasOne().WithMany()
+ .HasForeignKey("Mainproductid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_attachedproduct_product"),
+ j =>
+ {
+ j.HasKey("Mainproductid", "Attachedproductid").HasName("attachedproduct_pkey");
+ j.ToTable("attachedproduct");
+ j.IndexerProperty("Mainproductid").HasColumnName("mainproductid");
+ j.IndexerProperty("Attachedproductid").HasColumnName("attachedproductid");
+ });
+
+ entity.HasMany(d => d.Mainproducts).WithMany(p => p.Attachedproducts)
+ .UsingEntity>(
+ "Attachedproduct",
+ r => r.HasOne().WithMany()
+ .HasForeignKey("Mainproductid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_attachedproduct_product"),
+ l => l.HasOne().WithMany()
+ .HasForeignKey("Attachedproductid")
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_attachedproduct_product1"),
+ j =>
+ {
+ j.HasKey("Mainproductid", "Attachedproductid").HasName("attachedproduct_pkey");
+ j.ToTable("attachedproduct");
+ j.IndexerProperty("Mainproductid").HasColumnName("mainproductid");
+ j.IndexerProperty("Attachedproductid").HasColumnName("attachedproductid");
+ });
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("productphoto_pkey");
+
+ entity.ToTable("productphoto");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('productphoto_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Photopath)
+ .HasMaxLength(1000)
+ .HasColumnName("photopath");
+ entity.Property(e => e.Productid).HasColumnName("productid");
+
+ entity.HasOne(d => d.Product).WithMany(p => p.Productphotos)
+ .HasForeignKey(d => d.Productid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_productphoto_product");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("productsale_pkey");
+
+ entity.ToTable("productsale");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('productsale_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Clientserviceid).HasColumnName("clientserviceid");
+ entity.Property(e => e.Productid).HasColumnName("productid");
+ entity.Property(e => e.Quantity).HasColumnName("quantity");
+ entity.Property(e => e.Saledate)
+ .HasColumnType("timestamp(6) without time zone")
+ .HasColumnName("saledate");
+
+ entity.HasOne(d => d.Clientservice).WithMany(p => p.Productsales)
+ .HasForeignKey(d => d.Clientserviceid)
+ .HasConstraintName("fk_productsale_clientservice");
+
+ entity.HasOne(d => d.Product).WithMany(p => p.Productsales)
+ .HasForeignKey(d => d.Productid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_productsale_product");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("service_pkey");
+
+ entity.ToTable("service");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('service_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Cost)
+ .HasPrecision(19, 4)
+ .HasColumnName("cost");
+ entity.Property(e => e.Description).HasColumnName("description");
+ entity.Property(e => e.Discount).HasColumnName("discount");
+ entity.Property(e => e.Durationinseconds).HasColumnName("durationinseconds");
+ entity.Property(e => e.Mainimagepath)
+ .HasMaxLength(1000)
+ .HasColumnName("mainimagepath");
+ entity.Property(e => e.Title)
+ .HasMaxLength(100)
+ .HasColumnName("title");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("servicephoto_pkey");
+
+ entity.ToTable("servicephoto");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('servicephoto_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Photopath)
+ .HasMaxLength(1000)
+ .HasColumnName("photopath");
+ entity.Property(e => e.Serviceid).HasColumnName("serviceid");
+
+ entity.HasOne(d => d.Service).WithMany(p => p.Servicephotos)
+ .HasForeignKey(d => d.Serviceid)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("fk_servicephoto_service");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("tag_pkey");
+
+ entity.ToTable("tag");
+
+ entity.Property(e => e.Id)
+ .HasDefaultValueSql("nextval('tag_seq'::regclass)")
+ .HasColumnName("id");
+ entity.Property(e => e.Color)
+ .HasMaxLength(6)
+ .IsFixedLength()
+ .HasColumnName("color");
+ entity.Property(e => e.Title)
+ .HasMaxLength(30)
+ .HasColumnName("title");
+ });
+ modelBuilder.HasSequence("client_seq");
+ modelBuilder.HasSequence("clientservice_seq");
+ modelBuilder.HasSequence("documentbyservice_seq");
+ modelBuilder.HasSequence("manufacturer_seq");
+ modelBuilder.HasSequence("product_seq");
+ modelBuilder.HasSequence("productphoto_seq");
+ modelBuilder.HasSequence("productsale_seq");
+ modelBuilder.HasSequence("service_seq");
+ modelBuilder.HasSequence("servicephoto_seq");
+ modelBuilder.HasSequence("tag_seq");
+
+ OnModelCreatingPartial(modelBuilder);
+ }
+
+ partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+}
diff --git a/demo-12-14/Models/Productsale.cs b/demo-12-14/Models/Productsale.cs
new file mode 100644
index 0000000..a37fba8
--- /dev/null
+++ b/demo-12-14/Models/Productsale.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Productsale
+{
+ public int Id { get; set; }
+
+ public DateTime Saledate { get; set; }
+
+ public int Productid { get; set; }
+
+ public int Quantity { get; set; }
+
+ public int? Clientserviceid { get; set; }
+
+ public virtual Clientservice? Clientservice { get; set; }
+
+ public virtual Product Product { get; set; } = null!;
+}
diff --git a/demo-12-14/Models/Service.cs b/demo-12-14/Models/Service.cs
new file mode 100644
index 0000000..a90b740
--- /dev/null
+++ b/demo-12-14/Models/Service.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Service
+{
+ public int Id { get; set; }
+
+ public string Title { get; set; } = null!;
+
+ public decimal Cost { get; set; }
+
+ public int Durationinseconds { get; set; }
+
+ public string? Description { get; set; }
+
+ public double? Discount { get; set; }
+
+ public string? Mainimagepath { get; set; }
+
+ public virtual ICollection Clientservices { get; set; } = new List();
+
+ public virtual ICollection Servicephotos { get; set; } = new List();
+}
diff --git a/demo-12-14/Models/Servicephoto.cs b/demo-12-14/Models/Servicephoto.cs
new file mode 100644
index 0000000..3847b6b
--- /dev/null
+++ b/demo-12-14/Models/Servicephoto.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Servicephoto
+{
+ public int Id { get; set; }
+
+ public int Serviceid { get; set; }
+
+ public string Photopath { get; set; } = null!;
+
+ public virtual Service Service { get; set; } = null!;
+}
diff --git a/demo-12-14/Models/Tag.cs b/demo-12-14/Models/Tag.cs
new file mode 100644
index 0000000..b8911d2
--- /dev/null
+++ b/demo-12-14/Models/Tag.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace demoModels;
+
+public partial class Tag
+{
+ public int Id { get; set; }
+
+ public string Title { get; set; } = null!;
+
+ public string Color { get; set; } = null!;
+
+ public virtual ICollection Clients { get; set; } = new List();
+}
diff --git a/demo-12-14/ProductWindow.axaml b/demo-12-14/ProductWindow.axaml
new file mode 100644
index 0000000..e737c48
--- /dev/null
+++ b/demo-12-14/ProductWindow.axaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo-12-14/ProductWindow.axaml.cs b/demo-12-14/ProductWindow.axaml.cs
new file mode 100644
index 0000000..d74cdf5
--- /dev/null
+++ b/demo-12-14/ProductWindow.axaml.cs
@@ -0,0 +1,80 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Markup.Xaml;
+using Avalonia.Media.Imaging;
+using Avalonia.Platform.Storage;
+using demoModels;
+using System;
+using System.ComponentModel.Design;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace demo;
+
+public partial class ProductWindow : Window
+{
+ public string PathToImage = string.Empty;
+
+
+
+ public ProductWindow()
+ {
+ using ProductsTradeContext context = new ProductsTradeContext();
+ InitializeComponent();
+ ProductId.IsVisible = false;
+ ProductIdLabel.IsVisible = false;
+ ProductIdLabel.IsVisible = false;
+ EditButton.IsVisible = false;
+ ProductManufacture.ItemsSource = context.Manufacturers.Select(it => it.Name).ToList();
+
+ }
+ private async Task SelectImageAndSaveImage()
+ {
+ var showDilaog = StorageProvider.OpenFilePickerAsync(
+ new Avalonia.Platform.Storage.FilePickerOpenOptions()
+ {
+ Title = " ",
+ FileTypeFilter = new[] { FilePickerFileTypes.ImageAll }
+ });
+ var storageFile = await showDilaog;
+ try
+ {
+ var bmp = new Bitmap(storageFile.First().TryGetLocalPath());
+ string path = $" \\{Guid.NewGuid()}.jpg";
+ bmp.Save(path);
+ PathToImage = path;
+ return bmp;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ public async void AddClick(object sender, RoutedEventArgs e)
+ {
+ using ProductsTradeContext context = new ProductsTradeContext();
+ ProductPresenter presenter = new ProductPresenter();
+ if (!decimal.TryParse(ProductCost.Text, out decimal cost)) return;
+ if (cost < 0) return;
+ presenter.Cost = cost;
+ if (string.IsNullOrEmpty(ProductName.Text)) return;
+ presenter.Title = ProductName.Text;
+ if (string.IsNullOrEmpty(ProductDesc.Text)) return;
+ presenter.Description = ProductDesc.Text;
+ var findManufacture = context.Manufacturers.First(it => it.Name == ProductManufacture.SelectedItem.ToString());
+ if (findManufacture == null) return;
+ presenter.Manufacturerid = findManufacture.Id;
+ presenter.Isactive = IsActiveBox.IsPressed;
+ if (String.IsNullOrEmpty(PathToImage)) return;
+ presenter.Mainimagepath = PathToImage;
+ Close(presenter);
+ }
+ public void EditClick(object sender, RoutedEventArgs e)
+ {
+ }
+ public async void AddImageClick(object sender, RoutedEventArgs e)
+ {
+ ProductImage.Source = await SelectImageAndSaveImage();
+ }
+}
\ No newline at end of file
diff --git a/demo-12-14/Program.cs b/demo-12-14/Program.cs
new file mode 100644
index 0000000..ccecd1b
--- /dev/null
+++ b/demo-12-14/Program.cs
@@ -0,0 +1,22 @@
+using Avalonia;
+using System;
+
+namespace demo
+{
+ internal class Program
+ {
+ // Initialization code. Don't use any Avalonia, third-party APIs or any
+ // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
+ // yet and stuff might break.
+ [STAThread]
+ public static void Main(string[] args) => BuildAvaloniaApp()
+ .StartWithClassicDesktopLifetime(args);
+
+ // Avalonia configuration, don't remove; also used by visual designer.
+ public static AppBuilder BuildAvaloniaApp()
+ => AppBuilder.Configure()
+ .UsePlatformDetect()
+ .WithInterFont()
+ .LogToTrace();
+ }
+}
diff --git a/demo-12-14/app.manifest b/demo-12-14/app.manifest
new file mode 100644
index 0000000..53fabcb
--- /dev/null
+++ b/demo-12-14/app.manifest
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo-12-14/demo-12-14.csproj b/demo-12-14/demo-12-14.csproj
new file mode 100644
index 0000000..9d81835
--- /dev/null
+++ b/demo-12-14/demo-12-14.csproj
@@ -0,0 +1,25 @@
+
+
+ WinExe
+ net8.0
+ enable
+ true
+ app.manifest
+ true
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+