фикс с письмами в вебе и перекочевание измнений в реализациях стораджах

This commit is contained in:
frog24 2024-05-18 17:34:54 +04:00
parent fb98928ef9
commit 487be858e0
10 changed files with 512 additions and 137 deletions

View File

@ -24,11 +24,17 @@ namespace ComputersShopFileImplements.Implements
} }
public List<OrderViewModel> GetFiltredList(OrderSearchModel model) public List<OrderViewModel> GetFiltredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
{ {
return new(); return new();
} }
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); return source.Orders
.Where(x => x.Id == model.Id ||
model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo ||
x.ClientId == model.ClientId ||
model.Status.Equals(x.Status))
.Select(x => GetViewModel(x))
.ToList();
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
@ -36,6 +42,10 @@ namespace ComputersShopFileImplements.Implements
{ {
return null; return null;
} }
if (model.ImplementerId.HasValue && model.Status != null)
{
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
}
return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)); return GetViewModel(source.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id));
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -77,7 +87,9 @@ namespace ComputersShopFileImplements.Implements
var viewModel = order.GetViewModel; var viewModel = order.GetViewModel;
var computer = source.Computers.FirstOrDefault(x => x.Id == order.ComputerId); var computer = source.Computers.FirstOrDefault(x => x.Id == order.ComputerId);
viewModel.ComputerName = computer?.ComputerName; viewModel.ComputerName = computer?.ComputerName;
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
viewModel.ClientFIO = client.ClientFIO;
return viewModel; return viewModel;
} }
} }
} }

View File

@ -111,7 +111,7 @@ namespace ComputersShopBusinessLogic.BusinessLogics
_logger.LogWarning("Update operation failed"); _logger.LogWarning("Update operation failed");
return false; return false;
} }
SendOrderMessage(order.ClientId, $"DNS, Заказ №{order.Id}", $"Заказ №{order.Id} от {order.DateCreate} на сумму {order.Sum:0.00} принят"); SendOrderMessage(order.ClientId, $"DNS, Заказ №{order.Id}", $"Статус заказа №{order.Id} от {order.DateCreate} на сумму {order.Sum:0.00} изменен");
return true; return true;
} }
public bool TakeOrderInWork(OrderBindingModel model) public bool TakeOrderInWork(OrderBindingModel model)

View File

@ -15,9 +15,11 @@ namespace ComputersShopDatabaseImplements
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=ComputersShopDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseNpgsql(@"Host=localhost;Database=ComputersShop_db;Username=postgres;Password=postgres");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
} }
public virtual DbSet<Component> Components { set; get; } public virtual DbSet<Component> Components { set; get; }
public virtual DbSet<Computer> Computers { set; get; } public virtual DbSet<Computer> Computers { set; get; }

View File

@ -18,6 +18,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,16 +3,16 @@ using System;
using ComputersShopDatabaseImplements; using ComputersShopDatabaseImplements;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace ComputersShopDatabaseImplements.Migrations namespace ComputersShopDatabaseImplements.Migrations
{ {
[DbContext(typeof(ComputersShopDatabase))] [DbContext(typeof(ComputersShopDatabase))]
[Migration("20240516145540_fix")] [Migration("20240518131102_fix")]
partial class fix partial class fix
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -21,29 +21,29 @@ namespace ComputersShopDatabaseImplements.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.16") .HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 63);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b => modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO") b.Property<string>("ClientFIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
@ -54,16 +54,16 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");
@ -74,16 +74,16 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComputerName") b.Property<string>("ComputerName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<double>("Price") b.Property<double>("Price")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");
@ -94,18 +94,18 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId") b.Property<int>("ComponentId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("ComputerId") b.Property<int>("ComputerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
@ -120,23 +120,23 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO") b.Property<string>("ImplementerFIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<int>("Qualification") b.Property<int>("Qualification")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("WorkExperience") b.Property<int>("WorkExperience")
.HasColumnType("int"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
@ -146,25 +146,25 @@ namespace ComputersShopDatabaseImplements.Migrations
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b => modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b =>
{ {
b.Property<string>("MessageId") b.Property<string>("MessageId")
.HasColumnType("nvarchar(450)"); .HasColumnType("text");
b.Property<string>("Body") b.Property<string>("Body")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<int?>("ClientId") b.Property<int?>("ClientId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<DateTime>("DateDelivery") b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<string>("SenderName") b.Property<string>("SenderName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Subject") b.Property<string>("Subject")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.HasKey("MessageId"); b.HasKey("MessageId");
@ -177,33 +177,33 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("ComputerId") b.Property<int>("ComputerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<int?>("ImplementerId") b.Property<int?>("ImplementerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<double>("Sum") b.Property<double>("Sum")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
@ -15,11 +16,11 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Clients", name: "Clients",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false), ClientFIO = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false), Email = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false) Password = table.Column<string>(type: "text", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -30,10 +31,10 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Components", name: "Components",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false), ComponentName = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false) Cost = table.Column<double>(type: "double precision", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -44,10 +45,10 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Computers", name: "Computers",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComputerName = table.Column<string>(type: "nvarchar(max)", nullable: false), ComputerName = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "float", nullable: false) Price = table.Column<double>(type: "double precision", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -58,12 +59,12 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Implementers", name: "Implementers",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false), ImplementerFIO = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false), Password = table.Column<string>(type: "text", nullable: false),
WorkExperience = table.Column<int>(type: "int", nullable: false), WorkExperience = table.Column<int>(type: "integer", nullable: false),
Qualification = table.Column<int>(type: "int", nullable: false) Qualification = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -74,12 +75,12 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Messages", name: "Messages",
columns: table => new columns: table => new
{ {
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false), MessageId = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: true), ClientId = table.Column<int>(type: "integer", nullable: true),
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false), SenderName = table.Column<string>(type: "text", nullable: false),
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false), DateDelivery = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false), Subject = table.Column<string>(type: "text", nullable: false),
Body = table.Column<string>(type: "nvarchar(max)", nullable: false) Body = table.Column<string>(type: "text", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -95,11 +96,11 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "ComputerComponents", name: "ComputerComponents",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComputerId = table.Column<int>(type: "int", nullable: false), ComputerId = table.Column<int>(type: "integer", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false), ComponentId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "int", nullable: false) Count = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -122,16 +123,16 @@ namespace ComputersShopDatabaseImplements.Migrations
name: "Orders", name: "Orders",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComputerId = table.Column<int>(type: "int", nullable: false), ComputerId = table.Column<int>(type: "integer", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false), ClientId = table.Column<int>(type: "integer", nullable: false),
ImplementerId = table.Column<int>(type: "int", nullable: true), ImplementerId = table.Column<int>(type: "integer", nullable: true),
Count = table.Column<int>(type: "int", nullable: false), Count = table.Column<int>(type: "integer", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false), Sum = table.Column<double>(type: "double precision", nullable: false),
Status = table.Column<int>(type: "int", nullable: false), Status = table.Column<int>(type: "integer", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false), DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true) DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -0,0 +1,296 @@
// <auto-generated />
using System;
using ComputersShopDatabaseImplements;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ComputersShopDatabaseImplements.Migrations
{
[DbContext(typeof(ComputersShopDatabase))]
[Migration("20240518131310_fix123")]
partial class fix123
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Computer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComputerName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Computers");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.ComputerComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("ComputerId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ComputerId");
b.ToTable("ComputerComponents");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Qualification")
.HasColumnType("integer");
b.Property<int>("WorkExperience")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b =>
{
b.Property<string>("MessageId")
.HasColumnType("text");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ClientId")
.HasColumnType("integer");
b.Property<DateTime>("DateDelivery")
.HasColumnType("timestamp without time zone");
b.Property<string>("SenderName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.HasKey("MessageId");
b.HasIndex("ClientId");
b.ToTable("Messages");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<int>("ComputerId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp without time zone");
b.Property<int?>("ImplementerId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComputerId");
b.HasIndex("ImplementerId");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.ComputerComponent", b =>
{
b.HasOne("ComputersShopDatabaseImplements.Models.Component", "Component")
.WithMany("ComputerComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputersShopDatabaseImplements.Models.Computer", "Computer")
.WithMany("Components")
.HasForeignKey("ComputerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Computer");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b =>
{
b.HasOne("ComputersShopDatabaseImplements.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId");
b.Navigation("Client");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Order", b =>
{
b.HasOne("ComputersShopDatabaseImplements.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputersShopDatabaseImplements.Models.Computer", "Computer")
.WithMany("Orders")
.HasForeignKey("ComputerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputersShopDatabaseImplements.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.Navigation("Client");
b.Navigation("Computer");
b.Navigation("Implementer");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Component", b =>
{
b.Navigation("ComputerComponents");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Computer", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Implementer", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputersShopDatabaseImplements.Migrations
{
/// <inheritdoc />
public partial class fix123 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -3,8 +3,8 @@ using System;
using ComputersShopDatabaseImplements; using ComputersShopDatabaseImplements;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
@ -18,29 +18,29 @@ namespace ComputersShopDatabaseImplements.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.16") .HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 63);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b => modelBuilder.Entity("ComputersShopDatabaseImplements.Models.Client", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO") b.Property<string>("ClientFIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
@ -51,16 +51,16 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");
@ -71,16 +71,16 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComputerName") b.Property<string>("ComputerName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<double>("Price") b.Property<double>("Price")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");
@ -91,18 +91,18 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId") b.Property<int>("ComponentId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("ComputerId") b.Property<int>("ComputerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
@ -117,23 +117,23 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO") b.Property<string>("ImplementerFIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<int>("Qualification") b.Property<int>("Qualification")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("WorkExperience") b.Property<int>("WorkExperience")
.HasColumnType("int"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
@ -143,25 +143,25 @@ namespace ComputersShopDatabaseImplements.Migrations
modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b => modelBuilder.Entity("ComputersShopDatabaseImplements.Models.MessageInfo", b =>
{ {
b.Property<string>("MessageId") b.Property<string>("MessageId")
.HasColumnType("nvarchar(450)"); .HasColumnType("text");
b.Property<string>("Body") b.Property<string>("Body")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<int?>("ClientId") b.Property<int?>("ClientId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<DateTime>("DateDelivery") b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<string>("SenderName") b.Property<string>("SenderName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.Property<string>("Subject") b.Property<string>("Subject")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("text");
b.HasKey("MessageId"); b.HasKey("MessageId");
@ -174,33 +174,33 @@ namespace ComputersShopDatabaseImplements.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("ComputerId") b.Property<int>("ComputerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("timestamp without time zone");
b.Property<int?>("ImplementerId") b.Property<int?>("ImplementerId")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("integer");
b.Property<double>("Sum") b.Property<double>("Sum")
.HasColumnType("float"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace ComputersShopListImplement.Implements namespace ComputersShopListImplement.Implements
{ {
public class OrderStorage: IOrderStorage public class OrderStorage : IOrderStorage
{ {
private readonly DataListSingleton _source; private readonly DataListSingleton _source;
public OrderStorage() public OrderStorage()
@ -34,11 +34,44 @@ namespace ComputersShopListImplement.Implements
{ {
return result; return result;
} }
foreach (var order in _source.Orders) if (model.DateFrom.HasValue && model.DateTo.HasValue)
{ {
if (order.Id == model.Id) foreach (var order in _source.Orders)
{ {
result.Add(AddComputerName(order.GetViewModel)); if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
{
result.Add(AddComputerName(order.GetViewModel));
}
}
}
if (model.ClientId != null)
{
foreach (var order in _source.Orders)
{
if (order.ClientId == model.ClientId)
{
result.Add(AddComputerName(order.GetViewModel));
}
}
}
if (model.ImplementerId != null)
{
foreach (var order in _source.Orders)
{
if (order.ImplementerId == model.ImplementerId)
{
result.Add(AddComputerName(order.GetViewModel));
}
}
}
if (model.Status != null)
{
foreach (var order in _source.Orders)
{
if (model.Status.Equals(order.Status))
{
result.Add(AddComputerName(order.GetViewModel));
}
} }
} }
return result; return result;
@ -55,6 +88,14 @@ namespace ComputersShopListImplement.Implements
{ {
return AddComputerName(order.GetViewModel); return AddComputerName(order.GetViewModel);
} }
else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
{
return order.GetViewModel;
}
else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
{
return order.GetViewModel;
}
} }
return null; return null;
} }
@ -111,4 +152,4 @@ namespace ComputersShopListImplement.Implements
return model; return model;
} }
} }
} }