Compare commits

..

2 Commits

17 changed files with 673 additions and 79 deletions

View File

@ -1,31 +0,0 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using Lab3.Database.Context;
using Lab3.Database.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
namespace Lab3.Database.Context.Configurations
{
public partial class StartEducationConfiguration : IEntityTypeConfiguration<StartEducation>
{
public void Configure(EntityTypeBuilder<StartEducation> entity)
{
entity.HasKey(e => e.Id).HasName("StartEducation_pkey");
entity.ToTable("StartEducation");
entity.Property(e => e.Id).ValueGeneratedNever();
entity.Property(e => e.DateTime).HasColumnType("timestamp without time zone");
entity.HasOne(d => d.Student).WithMany(p => p.StartEducations)
.HasForeignKey(d => d.StudentId)
.HasConstraintName("StartEducation_StudentId_fkey");
OnConfigurePartial(entity);
}
partial void OnConfigurePartial(EntityTypeBuilder<StartEducation> entity);
}
}

View File

@ -1,5 +1,7 @@
using Lab3.Database.Context; using Lab3.Database.Context;
using Lab3.Database.MappingProfiles; using Lab3.Database.MappingProfiles;
using Lab3.Database.Repository.Implementations;
using Lab3.Database.Repository.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -34,5 +36,14 @@ namespace Lab3.Database.Extensions
return services; return services;
} }
public static IServiceCollection AddRepositories(
this IServiceCollection services)
{
services.AddScoped<IStudentRepository, StudentRepository>();
services.AddScoped<IEducationFormRepository, EducationFormRepository>();
return services;
}
} }
} }

View File

@ -11,8 +11,4 @@
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Repository\Implementations\" />
</ItemGroup>
</Project> </Project>

View File

@ -6,7 +6,7 @@ namespace Lab3.Database.MappingProfiles
{ {
public class SessionMappingProfile : Profile public class SessionMappingProfile : Profile
{ {
SessionMappingProfile() public SessionMappingProfile()
{ {
_ = CreateMap<StudentSession, StudentSessionDTO>(); _ = CreateMap<StudentSession, StudentSessionDTO>();
_ = CreateMap<StudentSessionDTO, StudentSession>(); _ = CreateMap<StudentSessionDTO, StudentSession>();

View File

@ -0,0 +1,34 @@
using Lab3.Database.Context;
using Lab3.Database.Models;
using Lab3.Database.Repository.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Lab3.Database.Repository.Implementations
{
public class EducationFormRepository : IEducationFormRepository
{
private readonly COPContext _context;
public EducationFormRepository(COPContext context)
{
_context = context;
}
public async Task<IEnumerable<string>> Get()
{
return await _context.EducationForms
.Select(f => f.Name)
.ToListAsync();
}
public async Task Update(IEnumerable<string> educationForms)
{
await _context.EducationForms.ExecuteDeleteAsync();
await _context.EducationForms.AddRangeAsync(educationForms.Select(f => new EducationForm()
{
Id = Guid.NewGuid(),
Name = f,
}));
}
}
}

View File

@ -0,0 +1,35 @@
using AutoMapper;
using Lab3.Database.Context;
using Lab3.Database.DTO;
using Lab3.Database.Repository.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Lab3.Database.Repository.Implementations
{
public class StudentRepository : IStudentRepository
{
private readonly IMapper _mapper;
private readonly COPContext _context;
public StudentRepository(IMapper mapper, COPContext context)
{
_mapper = mapper;
_context = context;
}
public Task<List<StudentDTO>> Create(StudentDTO studentDTO) => throw new NotImplementedException();
public Task<StudentDTO> Delete(Guid id) => throw new NotImplementedException();
public async Task<List<StudentDTO>> Get(int limit = 10000, int offset = 0)
=> _mapper.Map<List<StudentDTO>>(
await _context.Students
.Include(s => s.StudentSessions)
.Skip(offset)
.Take(limit)
.ToListAsync());
public Task<StudentDTO> Get(Guid id) => throw new NotImplementedException();
public Task<StudentDTO> Update(StudentDTO studentDTO) => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,9 @@
namespace Lab3.Database.Repository.Interfaces
{
public interface IEducationFormRepository
{
Task<IEnumerable<string>> Get();
Task Update(IEnumerable<string> educationForms);
}
}

View File

@ -1,4 +1,6 @@
using Lab3.Database.Extensions; using Lab3.Database.Extensions;
using Lab3.Forms;
using Lab3.MappingProfiles;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -12,6 +14,24 @@ namespace Lab3.Extensions
{ {
services.AddDatabase(configuration); services.AddDatabase(configuration);
services.AddDbMapping(); services.AddDbMapping();
services.AddRepositories();
return services;
}
public static IServiceCollection AddForms(
this IServiceCollection services)
{
services.AddScoped<MainForm>();
services.AddScoped<CreateForm>();
return services;
}
public static IServiceCollection AddMapping(
this IServiceCollection services)
{
services.AddAutoMapper(typeof(StudentViewMappingProfile));
return services; return services;
} }

View File

@ -0,0 +1,316 @@
namespace Lab3.Forms
{
partial class CreateForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
customDateTimePicker1 = new CustomsComponentsVar2.CustomDateTimePicker();
visualSelectionComponent1 = new ComponentsLab.VisualSelectionComponent();
label1 = new Label();
label2 = new Label();
textBox1 = new TextBox();
label3 = new Label();
numericUpDown1 = new NumericUpDown();
label4 = new Label();
label5 = new Label();
label6 = new Label();
numericUpDown2 = new NumericUpDown();
label7 = new Label();
numericUpDown3 = new NumericUpDown();
label8 = new Label();
numericUpDown4 = new NumericUpDown();
label9 = new Label();
numericUpDown5 = new NumericUpDown();
label10 = new Label();
numericUpDown6 = new NumericUpDown();
button1 = new Button();
button2 = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown3).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown4).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown5).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown6).BeginInit();
SuspendLayout();
//
// customDateTimePicker1
//
customDateTimePicker1.Location = new Point(430, 32);
customDateTimePicker1.Name = "customDateTimePicker1";
customDateTimePicker1.Size = new Size(456, 55);
customDateTimePicker1.TabIndex = 0;
customDateTimePicker1.Value = new DateTime(2024, 11, 6, 22, 54, 54, 353);
//
// visualSelectionComponent1
//
visualSelectionComponent1.BorderStyle = BorderStyle.FixedSingle;
visualSelectionComponent1.comboBoxSelectedValue = "";
visualSelectionComponent1.Location = new Point(430, 114);
visualSelectionComponent1.Margin = new Padding(3, 4, 3, 4);
visualSelectionComponent1.Name = "visualSelectionComponent1";
visualSelectionComponent1.Size = new Size(211, 109);
visualSelectionComponent1.TabIndex = 1;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(430, 9);
label1.Name = "label1";
label1.Size = new Size(134, 20);
label1.TabIndex = 2;
label1.Text = "Дата поступления";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(436, 90);
label2.Name = "label2";
label2.Size = new Size(128, 20);
label2.TabIndex = 3;
label2.Text = "Форма обучения";
//
// textBox1
//
textBox1.Location = new Point(12, 60);
textBox1.Name = "textBox1";
textBox1.Size = new Size(315, 27);
textBox1.TabIndex = 4;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(12, 18);
label3.Name = "label3";
label3.Size = new Size(42, 20);
label3.TabIndex = 5;
label3.Text = "ФИО";
//
// numericUpDown1
//
numericUpDown1.DecimalPlaces = 2;
numericUpDown1.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown1.Location = new Point(12, 156);
numericUpDown1.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown1.Name = "numericUpDown1";
numericUpDown1.Size = new Size(150, 27);
numericUpDown1.TabIndex = 6;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(12, 101);
label4.Name = "label4";
label4.Size = new Size(107, 20);
label4.TabIndex = 7;
label4.Text = "Успеваемость";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(12, 133);
label5.Name = "label5";
label5.Size = new Size(65, 20);
label5.TabIndex = 8;
label5.Text = "Сессия1";
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(12, 188);
label6.Name = "label6";
label6.Size = new Size(65, 20);
label6.TabIndex = 10;
label6.Text = "Сессия2";
//
// numericUpDown2
//
numericUpDown2.DecimalPlaces = 2;
numericUpDown2.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown2.Location = new Point(12, 211);
numericUpDown2.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown2.Name = "numericUpDown2";
numericUpDown2.Size = new Size(150, 27);
numericUpDown2.TabIndex = 9;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(12, 247);
label7.Name = "label7";
label7.Size = new Size(65, 20);
label7.TabIndex = 12;
label7.Text = "Сессия3";
//
// numericUpDown3
//
numericUpDown3.DecimalPlaces = 2;
numericUpDown3.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown3.Location = new Point(12, 270);
numericUpDown3.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown3.Name = "numericUpDown3";
numericUpDown3.Size = new Size(150, 27);
numericUpDown3.TabIndex = 11;
//
// label8
//
label8.AutoSize = true;
label8.Location = new Point(177, 247);
label8.Name = "label8";
label8.Size = new Size(65, 20);
label8.TabIndex = 18;
label8.Text = "Сессия6";
//
// numericUpDown4
//
numericUpDown4.DecimalPlaces = 2;
numericUpDown4.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown4.Location = new Point(177, 270);
numericUpDown4.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown4.Name = "numericUpDown4";
numericUpDown4.Size = new Size(150, 27);
numericUpDown4.TabIndex = 17;
//
// label9
//
label9.AutoSize = true;
label9.Location = new Point(177, 188);
label9.Name = "label9";
label9.Size = new Size(65, 20);
label9.TabIndex = 16;
label9.Text = "Сессия5";
//
// numericUpDown5
//
numericUpDown5.DecimalPlaces = 2;
numericUpDown5.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown5.Location = new Point(177, 211);
numericUpDown5.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown5.Name = "numericUpDown5";
numericUpDown5.Size = new Size(150, 27);
numericUpDown5.TabIndex = 15;
//
// label10
//
label10.AutoSize = true;
label10.Location = new Point(177, 133);
label10.Name = "label10";
label10.Size = new Size(65, 20);
label10.TabIndex = 14;
label10.Text = "Сессия4";
//
// numericUpDown6
//
numericUpDown6.DecimalPlaces = 2;
numericUpDown6.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDown6.Location = new Point(177, 156);
numericUpDown6.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDown6.Name = "numericUpDown6";
numericUpDown6.Size = new Size(150, 27);
numericUpDown6.TabIndex = 13;
//
// button1
//
button1.Location = new Point(430, 258);
button1.Name = "button1";
button1.Size = new Size(164, 39);
button1.TabIndex = 19;
button1.Text = "Сохранить";
button1.UseVisualStyleBackColor = true;
//
// button2
//
button2.Location = new Point(624, 258);
button2.Name = "button2";
button2.Size = new Size(164, 39);
button2.TabIndex = 20;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
//
// CreateForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 309);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(label8);
Controls.Add(numericUpDown4);
Controls.Add(label9);
Controls.Add(numericUpDown5);
Controls.Add(label10);
Controls.Add(numericUpDown6);
Controls.Add(label7);
Controls.Add(numericUpDown3);
Controls.Add(label6);
Controls.Add(numericUpDown2);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(numericUpDown1);
Controls.Add(label3);
Controls.Add(textBox1);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(customDateTimePicker1);
Controls.Add(visualSelectionComponent1);
Name = "CreateForm";
Text = "CreateForm";
Load += CreateForm_Load;
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown3).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown4).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown5).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown6).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private CustomsComponentsVar2.CustomDateTimePicker customDateTimePicker1;
private ComponentsLab.VisualSelectionComponent visualSelectionComponent1;
private Label label1;
private Label label2;
private TextBox textBox1;
private Label label3;
private NumericUpDown numericUpDown1;
private Label label4;
private Label label5;
private Label label6;
private NumericUpDown numericUpDown2;
private Label label7;
private NumericUpDown numericUpDown3;
private Label label8;
private NumericUpDown numericUpDown4;
private Label label9;
private NumericUpDown numericUpDown5;
private Label label10;
private NumericUpDown numericUpDown6;
private Button button1;
private Button button2;
}
}

View File

@ -0,0 +1,17 @@
using Lab3.Database.Repository.Interfaces;
namespace Lab3.Forms
{
public partial class CreateForm : Form
{
public CreateForm(IStudentRepository student)
{
InitializeComponent();
}
private void CreateForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -28,12 +28,33 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); StudentsListBox = new ComponentsLibrary.ListBoxValues();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; SuspendLayout();
this.ClientSize = new System.Drawing.Size(800, 450); //
this.Text = "MainForm"; // StudentsListBox
//
StudentsListBox.Dock = DockStyle.Fill;
StudentsListBox.Location = new Point(0, 0);
StudentsListBox.Margin = new Padding(3, 4, 3, 4);
StudentsListBox.Name = "StudentsListBox";
StudentsListBox.SelectedIndex = -1;
StudentsListBox.Size = new Size(800, 450);
StudentsListBox.TabIndex = 0;
//
// MainForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(StudentsListBox);
Name = "MainForm";
Text = "MainForm";
Load += MainForm_LoadAsync;
ResumeLayout(false);
} }
#endregion #endregion
private ComponentsLibrary.ListBoxValues StudentsListBox;
} }
} }

View File

@ -1,20 +1,27 @@
using System; using AutoMapper;
using System.Collections.Generic; using Lab3.Database.Repository.Interfaces;
using System.ComponentModel; using Lab3.Models;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Lab3.Forms namespace Lab3.Forms
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
public MainForm() private readonly IStudentRepository _studentRepository;
private readonly IMapper _mapper;
public MainForm(
IStudentRepository repository,
IMapper mapper)
{ {
_studentRepository = repository;
_mapper = mapper;
InitializeComponent(); InitializeComponent();
} }
private async void MainForm_LoadAsync(object sender, EventArgs e)
{
var students = _mapper.Map<List<StudentViewModel>>(await _studentRepository.Get());
StudentsListBox.FillListBox(students);
}
} }
} }

View File

@ -12,8 +12,22 @@
<Folder Include="Logic\" /> <Folder Include="Logic\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryLab1" Version="1.0.0" />
<PackageReference Include="ComponentsLibraryLab2" Version="1.0.0" />
<PackageReference Include="Cop.Borovkov.Var3" Version="8.0.1" />
<PackageReference Include="CustomComponentsVar2" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Lab3.Database\Lab3.Database.csproj" /> <ProjectReference Include="..\Lab3.Database\Lab3.Database.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -8,7 +8,7 @@ namespace Lab3.MappingProfiles
{ {
public StudentViewMappingProfile() public StudentViewMappingProfile()
{ {
_ = CreateMap<StudentDTO, StudentViewModel>()\ _ = CreateMap<StudentDTO, StudentViewModel>()
; ;
} }
} }

View File

@ -1,3 +1,10 @@
using Lab3.Database.Extensions;
using Lab3.Extensions;
using Lab3.Forms;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Lab3 namespace Lab3
{ {
internal static class Program internal static class Program
@ -11,7 +18,25 @@ namespace Lab3
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1());
var app = CreateHostBuilder().Build();
Application.Run(app.Services.GetRequiredService<CreateForm>());
}
static IHostBuilder CreateHostBuilder()
{
return Host.CreateDefaultBuilder()
.ConfigureAppConfiguration(c
=> c.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true))
.ConfigureServices((context, services) => {
services.ConfigureDAL(context.Configuration);
services.AddMapping();
services.AddForms();
});
} }
} }
} }