в abstractMailWorker mainLogin и password пустые(
This commit is contained in:
parent
c8f16f65fe
commit
1cde2587b2
@ -5,7 +5,7 @@
|
||||
<add key="SmtpClientPort" value="587" />
|
||||
<add key="PopHost" value="pop.gmail.com" />
|
||||
<add key="PopPort" value="995" />
|
||||
<add key="MailLogin" value="iskander04444@gmail.com" />
|
||||
<add key="MailLogin" value="labwork7cacawa@gmail.com" />
|
||||
<add key="MailPassword" value="123" />
|
||||
</appSettings>
|
||||
</configuration>
|
@ -9,15 +9,16 @@ namespace FishFactory.Forms
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private IWorkProcess _workProcess;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
}
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
|
@ -30,9 +30,9 @@ namespace FishFactory
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
try
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
|
@ -5,6 +5,7 @@ using FishFactoryContracts.SearchModels;
|
||||
using FishFactoryContracts.StoragesContracts;
|
||||
using FishFactoryContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
{
|
||||
@ -96,14 +97,14 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО пользователя", nameof(model.ClientFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина пользователя", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email) || !Regex.IsMatch(model.Email, @"^[a-z0-9._%+-]+\@([a-z0-9-]+\.)+[a-z]{2,4}$"))
|
||||
{
|
||||
throw new ArgumentException("Почта не соответствует требованиям", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password) || !Regex.IsMatch(model.Password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9\n]).{10,50}$"))
|
||||
{
|
||||
throw new ArgumentNullException("Пароль не соответствует требованиям", nameof(model.Password));
|
||||
}
|
||||
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Id:{Id}", model.ClientFIO, model.Email, model.Id);
|
||||
var element = _ClientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
|
@ -14,7 +14,6 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
static readonly object _locker = new object();
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker)
|
||||
{
|
||||
@ -71,21 +70,18 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
}
|
||||
|
||||
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = order.ClientEmail,
|
||||
Subject = $"Новый заказ создан. Номер заказа - {order.Id}",
|
||||
Text = $"Ваш заказ номер {order.Id} на текстиль {order.CannedName} от {order.DateCreate} на сумму {order.Sum} принят."
|
||||
}));
|
||||
{
|
||||
MailAddress = order.ClientEmail,
|
||||
Subject = $"Новый заказ создан. Номер заказа - {order.Id}",
|
||||
Text = $"Ваш заказ номер {order.Id} на текстиль {order.CannedName} от {order.DateCreate} на сумму {order.Sum} принят."
|
||||
}));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
return ToNextStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
return ToNextStatus(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
@ -117,10 +113,6 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
model.Status = element.Status;
|
||||
model.Count = element.Count;
|
||||
model.Sum = element.Sum;
|
||||
if (!model.ImplementerId.HasValue)
|
||||
{
|
||||
model.ImplementerId = element.ImplementerId;
|
||||
}
|
||||
|
||||
if (model.Status != orderStatus - 1)
|
||||
{
|
||||
@ -129,7 +121,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
}
|
||||
model.Status = orderStatus;
|
||||
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
@ -141,14 +133,14 @@ namespace FishFactoryBusinessLogic.BusinessLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = element.ClientEmail,
|
||||
Subject = $"Изменение статуса заказа номер {element.Id}",
|
||||
Text = $"У заказа номер {element.Id} изменен статус на {orderStatus}"
|
||||
}));
|
||||
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = element.ClientEmail,
|
||||
Subject = $"Изменение статуса заказа номер {element.Id}",
|
||||
Text = $"У заказа номер {element.Id} изменен статус на {orderStatus}"
|
||||
}));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||
<PackageReference Include="MailKit" Version="4.5.0" />
|
||||
<PackageReference Include="MailKit" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FishFactoryContracts.BindingModels;
|
||||
using FishFactoryBusinessLogic.BusinessLogic;
|
||||
using FishFactoryContracts.BindingModels;
|
||||
using FishFactoryContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -32,8 +33,7 @@ namespace FishFactoryBusinessLogic.MailWorker
|
||||
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) ||
|
||||
string.IsNullOrEmpty(_mailPassword))
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -68,9 +68,9 @@ namespace FishFactoryBusinessLogic.MailWorker
|
||||
}
|
||||
var list = await ReceiveMailAsync();
|
||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||
foreach (var mail in list)
|
||||
foreach (var mail in list)
|
||||
{
|
||||
_messageInfoLogic.Create(mail);
|
||||
_messageInfoLogic.Create(mail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using AbstractShopContracts.ViewModels
|
||||
@using FishFactoryContracts.ViewModels
|
||||
@model List<MessageInfoViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Mails";
|
||||
|
@ -15,17 +15,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
/// <summary>
|
||||
/// Готов
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
/// <summary>
|
||||
/// Доставлен
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace FishFactoryContracts.ViewModels
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Исполнитель")]
|
||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||
public string? ImplementerFIO { get; set; } = null;
|
||||
public int CannedId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string CannedName { get; set; } = string.Empty;
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace FishFactoryDataModel.Models
|
||||
{
|
||||
public interface IImplementerModel
|
||||
public interface IImplementerModel : IId
|
||||
{
|
||||
string ImplementerFIO { get; }
|
||||
string Password { get; }
|
||||
|
@ -16,7 +16,11 @@ namespace FishFactoryDatabaseImplement.Implements
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
using var context = new FishFactoryDatabase();
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FishFactoryDatabase();
|
||||
return context.Clients.Where(c =>
|
||||
(!model.Id.HasValue || c.Id == model.Id) &&
|
||||
(string.IsNullOrEmpty(model.Email) || c.Email.Contains(model.Email)) &&
|
||||
|
@ -26,8 +26,9 @@ namespace FishFactoryDatabaseImplement.Implements
|
||||
|
||||
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FishFactoryDatabase();
|
||||
|
@ -38,12 +38,12 @@ namespace FishFactoryDatabaseImplement.Implements
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FishFactoryDatabase();
|
||||
return context.Orders
|
||||
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FishFactoryDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Canned)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
|
291
FishFactoryDatabaseImplement/Migrations/20240514161521_implementer2.Designer.cs
generated
Normal file
291
FishFactoryDatabaseImplement/Migrations/20240514161521_implementer2.Designer.cs
generated
Normal file
@ -0,0 +1,291 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FishFactoryDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FishFactoryDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FishFactoryDatabase))]
|
||||
[Migration("20240514161521_implementer2")]
|
||||
partial class implementer2
|
||||
{
|
||||
/// <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("FishFactoryDatabaseImplement.Models.Canned", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CannedName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Canneds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CannedId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CannedId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("CannedComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.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("FishFactoryDatabaseImplement.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("FishFactoryDatabaseImplement.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("FishFactoryDatabaseImplement.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("MessageInfos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CannedId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.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("CannedId");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
|
||||
{
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("CannedId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("CannedComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Canned");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("CannedId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Order")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.Navigation("Canned");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("CannedComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Order");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FishFactoryDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class implementer2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MessageInfos",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "text", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: true),
|
||||
SenderName = table.Column<string>(type: "text", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Subject = table.Column<string>(type: "text", nullable: false),
|
||||
Body = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MessageInfos", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_MessageInfos_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MessageInfos_ClientId",
|
||||
table: "MessageInfos",
|
||||
column: "ClientId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "MessageInfos");
|
||||
}
|
||||
}
|
||||
}
|
@ -140,6 +140,36 @@ namespace FishFactoryDatabaseImplement.Migrations
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.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("MessageInfos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -202,6 +232,15 @@ namespace FishFactoryDatabaseImplement.Migrations
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
||||
|
@ -1,6 +1,7 @@
|
||||
using FishFactoryContracts.BindingModels;
|
||||
using FishFactoryContracts.ViewModels;
|
||||
using FishFactoryDataModel.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FishFactoryDatabaseImplement.Models
|
||||
@ -11,8 +12,10 @@ namespace FishFactoryDatabaseImplement.Models
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<MessageInfo> ClientMessages { get; set; } = new();
|
||||
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
|
@ -13,9 +13,9 @@ namespace FishFactoryDatabaseImplement.Models
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public int WorkExperience { get; private set; }
|
||||
public int WorkExperience { get; private set; } = 0;
|
||||
|
||||
public int Qualification { get; private set; }
|
||||
public int Qualification { get; private set; } = 0;
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Order { get; set; } = new();
|
||||
|
||||
|
@ -39,8 +39,8 @@ namespace FishFactoryDatabaseImplement.Models
|
||||
ClientId = model.ClientId,
|
||||
Client = context.Clients.First(x => x.Id == model.ClientId),
|
||||
ImplementerId = model.ImplementerId,
|
||||
Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null,
|
||||
Count = model.Count,
|
||||
Implementer = model.ImplementerId == null ? null : context.Implementers.First(i => i.Id == model.ImplementerId),
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
@ -72,8 +72,9 @@ namespace FishFactoryDatabaseImplement.Models
|
||||
CannedName = Canned.CannedName,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = Client.ClientFIO,
|
||||
ImplementerId = ImplementerId,
|
||||
ImplementerFIO = Implementer?.ImplementerFIO,
|
||||
ClientEmail = Client.Email,
|
||||
ImplementerId = ImplementerId,
|
||||
ImplementerFIO = Implementer == null ? string.Empty : Implementer.ImplementerFIO,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
@ -1,6 +1,7 @@
|
||||
using FishFactoryContracts.BindingModels;
|
||||
using FishFactoryContracts.ViewModels;
|
||||
using FishFactoryDataModel.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FishFactoryFileImplement.Models
|
||||
{
|
||||
@ -35,7 +36,24 @@ namespace FishFactoryFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
public static MessageInfo? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Body = element.Attribute("Body")!.Value,
|
||||
Subject = element.Attribute("Subject")!.Value,
|
||||
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||
MessageId = element.Attribute("MessageId")!.Value,
|
||||
SenderName = element.Attribute("SenderName")!.Value,
|
||||
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||
};
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
Subject = Subject,
|
||||
|
@ -5,5 +5,12 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopPort": "995",
|
||||
"MailLogin": "labwork7cacawa@gmail.com",
|
||||
"MailPassword": "123"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user