diff --git a/zooManagerPro.slnx b/zooManagerPro.slnx new file mode 100644 index 0000000..9f6d965 --- /dev/null +++ b/zooManagerPro.slnx @@ -0,0 +1,3 @@ + + + diff --git a/zooManagerPro/App.axaml b/zooManagerPro/App.axaml new file mode 100644 index 0000000..ac28a9e --- /dev/null +++ b/zooManagerPro/App.axaml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/zooManagerPro/App.axaml.cs b/zooManagerPro/App.axaml.cs new file mode 100644 index 0000000..e0c69cb --- /dev/null +++ b/zooManagerPro/App.axaml.cs @@ -0,0 +1,32 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Data.Core; +using Avalonia.Data.Core.Plugins; +using Avalonia.Markup.Xaml; +using System.Linq; +using zooManagerPro.ViewModels; +using zooManagerPro.Views; + +namespace zooManagerPro +{ + 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 + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } + } +} \ No newline at end of file diff --git a/zooManagerPro/Assets/avalonia-logo.ico b/zooManagerPro/Assets/avalonia-logo.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/zooManagerPro/Assets/avalonia-logo.ico differ diff --git a/zooManagerPro/Context/ZooManagerProContext.cs b/zooManagerPro/Context/ZooManagerProContext.cs new file mode 100644 index 0000000..b7d4847 --- /dev/null +++ b/zooManagerPro/Context/ZooManagerProContext.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using zooManagerPro.Models; + +namespace zooManagerPro.Context; + +public partial class ZooManagerProContext : DbContext +{ + public ZooManagerProContext() + { + } + + public ZooManagerProContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Animals { get; set; } + + public virtual DbSet AnimalsFeedings { get; set; } + + public virtual DbSet ClimateZones { get; set; } + + public virtual DbSet DietaryRegimen { get; set; } + + public virtual DbSet Employees { get; set; } + + public virtual DbSet Enclosures { get; set; } + + public virtual DbSet EnclosureStatuses { get; set; } + + public virtual DbSet Features { get; set; } + + public virtual DbSet Genders { get; set; } + + public virtual DbSet HealthStatuses { get; set; } + + public virtual DbSet Species { get; set; } + + public virtual DbSet TypeOfEnclosures { get; set; } + + public virtual DbSet TypeOfFeedings { get; set; } + + public virtual DbSet UnitOfMasses { 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; Database=zooManagerPro; Username=postgres; Password=123"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_animal__pk"); + + entity.ToTable("Animal"); + + entity.HasOne(d => d.DietaryRegimen).WithMany(p => p.Animals) + .HasForeignKey(d => d.DietaryRegimenId) + .HasConstraintName("animal_dietaryregimen_fk"); + + entity.HasOne(d => d.Enclosure).WithMany(p => p.Animals) + .HasForeignKey(d => d.EnclosureId) + .HasConstraintName("animal_enclosure_fk"); + + entity.HasOne(d => d.Gender).WithMany(p => p.Animals) + .HasForeignKey(d => d.GenderId) + .HasConstraintName("animal_gender_fk"); + + entity.HasOne(d => d.HealthStatus).WithMany(p => p.Animals) + .HasForeignKey(d => d.HealthStatusId) + .HasConstraintName("animal_healthstatus_fk"); + + entity.HasOne(d => d.Species).WithMany(p => p.Animals) + .HasForeignKey(d => d.SpeciesId) + .HasConstraintName("animal_species_fk"); + + entity.HasMany(d => d.Features).WithMany(p => p.Animals) + .UsingEntity>( + "AnimalFeature", + r => r.HasOne().WithMany() + .HasForeignKey("FeatureId") + .HasConstraintName("animalfeature_features_fk"), + l => l.HasOne().WithMany() + .HasForeignKey("AnimalId") + .HasConstraintName("animalfeature_animal_fk"), + j => + { + j.HasKey("AnimalId", "FeatureId").HasName("animalfeature_pk"); + j.ToTable("AnimalFeature"); + }); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_animalsfeeding__pk"); + + entity.ToTable("AnimalsFeeding"); + + entity.Property(e => e.FeedingDateTime).HasColumnType("timestamp without time zone"); + + entity.HasOne(d => d.Animal).WithMany(p => p.AnimalsFeedings) + .HasForeignKey(d => d.AnimalId) + .HasConstraintName("animalsfeeding_animal_fk"); + + entity.HasOne(d => d.Employee).WithMany(p => p.AnimalsFeedings) + .HasForeignKey(d => d.EmployeeId) + .HasConstraintName("animalsfeeding_employee_fk"); + + entity.HasOne(d => d.TypeOfFeeding).WithMany(p => p.AnimalsFeedings) + .HasForeignKey(d => d.TypeOfFeedingId) + .HasConstraintName("animalsfeeding_typeoffeeding_fk"); + + entity.HasOne(d => d.UnitOfMass).WithMany(p => p.AnimalsFeedings) + .HasForeignKey(d => d.UnitOfMassId) + .HasConstraintName("animalsfeeding_unitofmass_fk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_climatezone__pk"); + + entity.ToTable("ClimateZone"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_dietaryregimen__pk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_employee__pk"); + + entity.ToTable("Employee"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_enclosure__pk"); + + entity.ToTable("Enclosure"); + + entity.HasOne(d => d.ClimateZone).WithMany(p => p.Enclosures) + .HasForeignKey(d => d.ClimateZoneId) + .HasConstraintName("enclosure_climatezone_fk"); + + entity.HasOne(d => d.EnclosureStatus).WithMany(p => p.Enclosures) + .HasForeignKey(d => d.EnclosureStatusId) + .HasConstraintName("enclosure_enclosurestatus_fk"); + + entity.HasOne(d => d.TypeOfEnclosure).WithMany(p => p.Enclosures) + .HasForeignKey(d => d.TypeOfEnclosureId) + .HasConstraintName("enclosure_typeofenclosure_fk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_enclosurestatus__pk"); + + entity.ToTable("EnclosureStatus"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_features__pk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_gender__pk"); + + entity.ToTable("Gender"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_healthstatus__pk"); + + entity.ToTable("HealthStatus"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_species__pk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_typeofenclosure__pk"); + + entity.ToTable("TypeOfEnclosure"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_typeoffeeding__pk"); + + entity.ToTable("TypeOfFeeding"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("_unitofmass__pk"); + + entity.ToTable("UnitOfMass"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/zooManagerPro/Models/Animal.cs b/zooManagerPro/Models/Animal.cs new file mode 100644 index 0000000..8d78ffe --- /dev/null +++ b/zooManagerPro/Models/Animal.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Animal +{ + public int Id { get; set; } + + public string AnimalName { get; set; } = null!; + + public int SpeciesId { get; set; } + + public int GenderId { get; set; } + + public DateOnly DateOfBirth { get; set; } + + public int DietaryRegimenId { get; set; } + + public int HealthStatusId { get; set; } + + public DateOnly LastDayOfVeterinaryExamination { get; set; } + + public int EnclosureId { get; set; } + + public virtual ICollection AnimalsFeedings { get; set; } = new List(); + + public virtual DietaryRegiman DietaryRegimen { get; set; } = null!; + + public virtual Enclosure Enclosure { get; set; } = null!; + + public virtual Gender Gender { get; set; } = null!; + + public virtual HealthStatus HealthStatus { get; set; } = null!; + + public virtual Species Species { get; set; } = null!; + + public virtual ICollection Features { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/AnimalsFeeding.cs b/zooManagerPro/Models/AnimalsFeeding.cs new file mode 100644 index 0000000..e6b0a9e --- /dev/null +++ b/zooManagerPro/Models/AnimalsFeeding.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class AnimalsFeeding +{ + public int Id { get; set; } + + public int AnimalId { get; set; } + + public DateTime FeedingDateTime { get; set; } + + public int TypeOfFeedingId { get; set; } + + public decimal FeedAmount { get; set; } + + public int UnitOfMassId { get; set; } + + public int EmployeeId { get; set; } + + public string? FeedingDescription { get; set; } + + public virtual Animal Animal { get; set; } = null!; + + public virtual Employee Employee { get; set; } = null!; + + public virtual TypeOfFeeding TypeOfFeeding { get; set; } = null!; + + public virtual UnitOfMass UnitOfMass { get; set; } = null!; +} diff --git a/zooManagerPro/Models/ClimateZone.cs b/zooManagerPro/Models/ClimateZone.cs new file mode 100644 index 0000000..c79a422 --- /dev/null +++ b/zooManagerPro/Models/ClimateZone.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class ClimateZone +{ + public int Id { get; set; } + + public string ClimateZoneName { get; set; } = null!; + + public virtual ICollection Enclosures { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/DietaryRegiman.cs b/zooManagerPro/Models/DietaryRegiman.cs new file mode 100644 index 0000000..34ce9dd --- /dev/null +++ b/zooManagerPro/Models/DietaryRegiman.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class DietaryRegiman +{ + public int Id { get; set; } + + public string DietName { get; set; } = null!; + + public virtual ICollection Animals { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/Employee.cs b/zooManagerPro/Models/Employee.cs new file mode 100644 index 0000000..7444aaa --- /dev/null +++ b/zooManagerPro/Models/Employee.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Employee +{ + public int Id { get; set; } + + public string Login { get; set; } = null!; + + public string Password { get; set; } = null!; + + public virtual ICollection AnimalsFeedings { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/Enclosure.cs b/zooManagerPro/Models/Enclosure.cs new file mode 100644 index 0000000..a5053ca --- /dev/null +++ b/zooManagerPro/Models/Enclosure.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Enclosure +{ + public int Id { get; set; } + + public int TypeOfEnclosureId { get; set; } + + public int Capacity { get; set; } + + public int MaxCapacity { get; set; } + + public int EnclosureStatusId { get; set; } + + public decimal Square { get; set; } + + public int ClimateZoneId { get; set; } + + public DateOnly LastDateOfTechnicalInsperation { get; set; } + + public virtual ICollection Animals { get; set; } = new List(); + + public virtual ClimateZone ClimateZone { get; set; } = null!; + + public virtual EnclosureStatus EnclosureStatus { get; set; } = null!; + + public virtual TypeOfEnclosure TypeOfEnclosure { get; set; } = null!; +} diff --git a/zooManagerPro/Models/EnclosureStatus.cs b/zooManagerPro/Models/EnclosureStatus.cs new file mode 100644 index 0000000..2d72565 --- /dev/null +++ b/zooManagerPro/Models/EnclosureStatus.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class EnclosureStatus +{ + public int Id { get; set; } + + public string EnclosureStatusName { get; set; } = null!; + + public virtual ICollection Enclosures { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/Feature.cs b/zooManagerPro/Models/Feature.cs new file mode 100644 index 0000000..40eaed2 --- /dev/null +++ b/zooManagerPro/Models/Feature.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Feature +{ + public int Id { get; set; } + + public string FeaturesName { get; set; } = null!; + + public virtual ICollection Animals { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/Gender.cs b/zooManagerPro/Models/Gender.cs new file mode 100644 index 0000000..c2a3285 --- /dev/null +++ b/zooManagerPro/Models/Gender.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Gender +{ + public int Id { get; set; } + + public string GenderName { get; set; } = null!; + + public virtual ICollection Animals { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/HealthStatus.cs b/zooManagerPro/Models/HealthStatus.cs new file mode 100644 index 0000000..de8bd55 --- /dev/null +++ b/zooManagerPro/Models/HealthStatus.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class HealthStatus +{ + public int Id { get; set; } + + public string HealthStatusName { get; set; } = null!; + + public virtual ICollection Animals { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/Species.cs b/zooManagerPro/Models/Species.cs new file mode 100644 index 0000000..9cc6fd3 --- /dev/null +++ b/zooManagerPro/Models/Species.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class Species +{ + public int Id { get; set; } + + public string SpeciesName { get; set; } = null!; + + public virtual ICollection Animals { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/TypeOfEnclosure.cs b/zooManagerPro/Models/TypeOfEnclosure.cs new file mode 100644 index 0000000..85cac5a --- /dev/null +++ b/zooManagerPro/Models/TypeOfEnclosure.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class TypeOfEnclosure +{ + public int Id { get; set; } + + public string TypeOfEnclosureName { get; set; } = null!; + + public virtual ICollection Enclosures { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/TypeOfFeeding.cs b/zooManagerPro/Models/TypeOfFeeding.cs new file mode 100644 index 0000000..430caa4 --- /dev/null +++ b/zooManagerPro/Models/TypeOfFeeding.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class TypeOfFeeding +{ + public int Id { get; set; } + + public string TypeOfFeedingName { get; set; } = null!; + + public virtual ICollection AnimalsFeedings { get; set; } = new List(); +} diff --git a/zooManagerPro/Models/UnitOfMass.cs b/zooManagerPro/Models/UnitOfMass.cs new file mode 100644 index 0000000..34768ba --- /dev/null +++ b/zooManagerPro/Models/UnitOfMass.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace zooManagerPro.Models; + +public partial class UnitOfMass +{ + public int Id { get; set; } + + public string UnitOfMassName { get; set; } = null!; + + public virtual ICollection AnimalsFeedings { get; set; } = new List(); +} diff --git a/zooManagerPro/Program.cs b/zooManagerPro/Program.cs new file mode 100644 index 0000000..bce0bda --- /dev/null +++ b/zooManagerPro/Program.cs @@ -0,0 +1,25 @@ +using Avalonia; +using System; + +namespace zooManagerPro +{ + internal sealed 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() +#if DEBUG + .WithDeveloperTools() +#endif + .WithInterFont() + .LogToTrace(); + } +} diff --git a/zooManagerPro/ViewModels/LoginViewModel.cs b/zooManagerPro/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..b927fcb --- /dev/null +++ b/zooManagerPro/ViewModels/LoginViewModel.cs @@ -0,0 +1,36 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using zooManagerPro.Context; +using zooManagerPro.Models; + +namespace zooManagerPro.ViewModels +{ + public partial class LoginViewModel : ObservableObject + { + [ObservableProperty] + public partial string Login { get; set; } + [ObservableProperty] + public partial string Password { get; set; } + + [RelayCommand] + public async Task EntranceAsync() + { + + await using ZooManagerProContext context = new(); + + if (context.Employees.FirstOrDefault(x => x.Login == Login && x.Password == Password) is Employee employee) + { + await MainView.Current.ReplaceAsync(new LoginView() // поменять + { + DataContext = new LoginViewModel() + }); + } + + } + } +} diff --git a/zooManagerPro/ViewModels/MainWindowViewModel.cs b/zooManagerPro/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..ac5facf --- /dev/null +++ b/zooManagerPro/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace zooManagerPro.ViewModels +{ + internal class MainWindowViewModel + { + } +} diff --git a/zooManagerPro/ViewModels/ViewModelBase.cs b/zooManagerPro/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..9e06d67 --- /dev/null +++ b/zooManagerPro/ViewModels/ViewModelBase.cs @@ -0,0 +1,8 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace zooManagerPro.ViewModels +{ + public abstract class ViewModelBase : ObservableObject + { + } +} diff --git a/zooManagerPro/Views/HomeView.axaml b/zooManagerPro/Views/HomeView.axaml new file mode 100644 index 0000000..0a2da61 --- /dev/null +++ b/zooManagerPro/Views/HomeView.axaml @@ -0,0 +1,45 @@ + + + + + +