LabWork07 is done.
This commit is contained in:
parent
e29059a4ce
commit
b9fb91e4ff
@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
@ -101,11 +102,11 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException("Invalid fullname of user", nameof(model.FullName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
if (string.IsNullOrEmpty(model.Email) || !Regex.IsMatch(model.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid email of user", nameof(model.Email));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
if (string.IsNullOrEmpty(model.Password) || !Regex.IsMatch(model.Password, @"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Invalid password of user", nameof(model.Password));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using DressAtelierContracts.BindingModels;
|
||||
using DressAtelierBusinessLogic.MailEmployee;
|
||||
using DressAtelierContracts.BindingModels;
|
||||
using DressAtelierContracts.BusinessLogicContracts;
|
||||
using DressAtelierContracts.SearchModels;
|
||||
using DressAtelierContracts.StorageContracts;
|
||||
@ -18,11 +19,14 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IClientStorage _clientStorage;
|
||||
private readonly AbstractMailEmployee _mailLogic;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IClientStorage clientStorage, AbstractMailEmployee mailLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_clientStorage = clientStorage;
|
||||
_mailLogic = mailLogic;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
@ -36,11 +40,19 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Accepted;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
|
||||
var order = _orderStorage.Insert(model);
|
||||
if (order == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
OrderViewModel orderViewModel = _orderStorage.GetElement(new OrderSearchModel { ID = order.ID});
|
||||
ClientViewModel clientViewModel = _clientStorage.GetElement(new ClientSearchModel { ID = orderViewModel.ClientID });
|
||||
|
||||
SendEmail(clientViewModel,orderViewModel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,8 +67,14 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
{
|
||||
ID = model.ID
|
||||
}).EmployeeID;
|
||||
|
||||
_orderStorage.Update(model);
|
||||
|
||||
OrderViewModel orderViewModel = _orderStorage.GetElement(new OrderSearchModel { ID = model.ID });
|
||||
ClientViewModel clientViewModel = _clientStorage.GetElement(new ClientSearchModel { ID = orderViewModel.ClientID });
|
||||
|
||||
SendEmail(clientViewModel, orderViewModel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -69,7 +87,14 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
{
|
||||
ID = model.ID
|
||||
}).EmployeeID;
|
||||
|
||||
_orderStorage.Update(model);
|
||||
|
||||
OrderViewModel orderViewModel = _orderStorage.GetElement(new OrderSearchModel { ID = model.ID });
|
||||
ClientViewModel clientViewModel = _clientStorage.GetElement(new ClientSearchModel { ID = orderViewModel.ClientID });
|
||||
|
||||
SendEmail(clientViewModel, orderViewModel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,6 +114,12 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("Update to in process status. ID:{ID}", model.ID);
|
||||
model.Status = OrderStatus.InProcess;
|
||||
_orderStorage.Update(model);
|
||||
|
||||
OrderViewModel orderViewModel = _orderStorage.GetElement(new OrderSearchModel { ID = model.ID });
|
||||
ClientViewModel clientViewModel = _clientStorage.GetElement(new ClientSearchModel { ID = orderViewModel.ClientID });
|
||||
|
||||
SendEmail(clientViewModel, orderViewModel);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -146,5 +177,37 @@ namespace DressAtelierBusinessLogic.BusinessLogic
|
||||
throw new InvalidOperationException("Order with such name already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
public void SendEmail(ClientViewModel clientModel ,OrderViewModel orderModel)
|
||||
{
|
||||
if(clientModel == null && orderModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MailSendInfoBindingModel mailModel;
|
||||
|
||||
if (orderModel.Status == OrderStatus.Accepted)
|
||||
{
|
||||
mailModel = new MailSendInfoBindingModel
|
||||
{
|
||||
Address = clientModel.Email,
|
||||
Subject = $"Order №{orderModel.ID}",
|
||||
Text = $"Your order №{orderModel.ID} by {orderModel.DateCreate} on {orderModel.Sum} was accepted!"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
mailModel = new MailSendInfoBindingModel
|
||||
{
|
||||
Address = clientModel.Email,
|
||||
Subject = $"Order №{orderModel.ID}",
|
||||
Text = $"Order №{orderModel.ID} status was changed to {orderModel.Status}"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
_mailLogic.MailSendAsync(mailModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,9 @@ using System.Net;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Pop3;
|
||||
using MailKit.Net;
|
||||
using MailKit.Security;
|
||||
using MailKit.Net.Pop3;
|
||||
|
||||
namespace DressAtelierBusinessLogic.MailEmployee
|
||||
{
|
||||
@ -45,7 +46,8 @@ namespace DressAtelierBusinessLogic.MailEmployee
|
||||
|
||||
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
||||
{
|
||||
var list = new List<MessageInfoBindingModel>(); using var client = new Pop3Client();
|
||||
var list = new List<MessageInfoBindingModel>();
|
||||
using var client = new Pop3Client();
|
||||
await Task.Run(() => {
|
||||
try
|
||||
{
|
||||
@ -59,10 +61,10 @@ namespace DressAtelierBusinessLogic.MailEmployee
|
||||
list.Add(new MessageInfoBindingModel
|
||||
{
|
||||
DeliveryDate = message.Date.DateTime,
|
||||
ID = message.MessageId,
|
||||
ID = message.MessageId,
|
||||
SenderName = mail.Address,
|
||||
Subject = message.Subject,
|
||||
Body = message.TextBody
|
||||
Body = message.TextBody != null ? message.TextBody : message.HtmlBody
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ namespace DressAtelierClientApp.Controllers
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
|
||||
[HttpGet] public IActionResult Mails()
|
||||
[HttpGet] public IActionResult Mail()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
@using DressAtelierContracts.ViewModels
|
||||
@model List<MessageInfoViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Mails";
|
||||
ViewData["Title"] = "Mail";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Orders</h1>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Personal data</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">E-mails</a>
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mail">E-mails</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Sign in</a>
|
||||
|
@ -48,7 +48,7 @@ namespace DressAtelierDatabaseImplement.Implements
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.ID.HasValue) { return null; }
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Clients.FirstOrDefault(x => (!(string.IsNullOrEmpty(model.Email)) && model.Email == x.Email) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
return context.Clients.FirstOrDefault(x => (!(string.IsNullOrEmpty(model.Email)) && model.Email.Equals(x.Email)) || (model.ID.HasValue && model.ID == x.ID))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
|
@ -43,13 +43,22 @@ namespace DressAtelierDatabaseImplement.Implements
|
||||
|
||||
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||
{
|
||||
|
||||
using var context = new DressAtelierDatabase();
|
||||
|
||||
model.ClientID = context.Clients.FirstOrDefault(x => x.Email.Equals(model.SenderName))?.ID;
|
||||
|
||||
var message = MessageInfo.Create(model);
|
||||
if(message == null)
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (GetElement(new MessageInfoSearchModel { ID = model.ID }) != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new DressAtelierDatabase();
|
||||
context.Messages.Add(message);
|
||||
context.SaveChanges();
|
||||
return message.GetViewModel;
|
||||
|
296
DressAtelierDatabaseImplement/Migrations/20230422104256_Messages.Designer.cs
generated
Normal file
296
DressAtelierDatabaseImplement/Migrations/20230422104256_Messages.Designer.cs
generated
Normal file
@ -0,0 +1,296 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DressAtelierDatabaseImplementation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DressAtelierDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DressAtelierDatabase))]
|
||||
[Migration("20230422104256_Messages")]
|
||||
partial class Messages
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("ID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("ClientID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DeliveryDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ClientID");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("DressName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Dresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaterialID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.HasIndex("MaterialID");
|
||||
|
||||
b.ToTable("DressMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ClientID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ClientID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientID");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Material", "Material")
|
||||
.WithMany("DressComponents")
|
||||
.HasForeignKey("MaterialID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dress");
|
||||
|
||||
b.Navigation("Material");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DressAtelierDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("EmployeeID");
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Dress");
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", b =>
|
||||
{
|
||||
b.Navigation("DressComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DressAtelierDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Messages : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientID = table.Column<int>(type: "int", nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DeliveryDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Messages_Clients_ClientID",
|
||||
column: x => x.ClientID,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "ID");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Messages_ClientID",
|
||||
table: "Messages",
|
||||
column: "ClientID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
}
|
||||
}
|
||||
}
|
@ -74,6 +74,36 @@ namespace DressAtelierDatabaseImplement.Migrations
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("ID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("ClientID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DeliveryDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ClientID");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
@ -183,6 +213,15 @@ namespace DressAtelierDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientID");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
|
@ -7,10 +7,10 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientHost": "smtp.rambler.ru",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopHost": "pop.rambler.ru",
|
||||
"PopPort": "995",
|
||||
"MailLogin": "ulstulabs4me@gmail.com",
|
||||
"MailPassword": "fmir rydi kqvu lklv"
|
||||
"MailLogin": "chelovek.labov@rambler.ru",
|
||||
"MailPassword": "Iloverpp4real"
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="SmtpClientHost" value="smtp.gmail.com" />
|
||||
<add key="SmtpClientHost" value="smtp.rambler.ru" />
|
||||
<add key="SmtpClientPort" value="587" />
|
||||
<add key="PopHost" value="pop.gmail.com" />
|
||||
<add key="PopHost" value="pop.rambler.ru" />
|
||||
<add key="PopPort" value="995" />
|
||||
<add key="MailLogin" value="ulstulabs4me@gmail.com" />
|
||||
<add key="MailPassword" value="fmir rydi kqvu lklv" />
|
||||
<add key="MailLogin" value="chelovek.labov@rambler.ru" />
|
||||
<add key="MailPassword" value="Iloverpp4real" />
|
||||
</appSettings>
|
||||
</configuration>
|
64
SewingDresses/FormEmails.Designer.cs
generated
Normal file
64
SewingDresses/FormEmails.Designer.cs
generated
Normal file
@ -0,0 +1,64 @@
|
||||
namespace SewingDresses
|
||||
{
|
||||
partial class FormEmails
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.emailsGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.emailsGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// emailsGridView
|
||||
//
|
||||
this.emailsGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.emailsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.emailsGridView.GridColor = System.Drawing.SystemColors.AppWorkspace;
|
||||
this.emailsGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.emailsGridView.Name = "emailsGridView";
|
||||
this.emailsGridView.RowTemplate.Height = 25;
|
||||
this.emailsGridView.Size = new System.Drawing.Size(776, 426);
|
||||
this.emailsGridView.TabIndex = 0;
|
||||
//
|
||||
// FormEmails
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.emailsGridView);
|
||||
this.Name = "FormEmails";
|
||||
this.Text = "FormEmails";
|
||||
this.Load += new System.EventHandler(this.FormEmails_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.emailsGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView emailsGridView;
|
||||
}
|
||||
}
|
53
SewingDresses/FormEmails.cs
Normal file
53
SewingDresses/FormEmails.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using DressAtelierContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SewingDresses
|
||||
{
|
||||
public partial class FormEmails : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
|
||||
public FormEmails(ILogger<FormEmails> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormEmails_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
emailsGridView.DataSource = list;
|
||||
emailsGridView.Columns["ClientID"].Visible = false;
|
||||
emailsGridView.Columns["ID"].Visible = false;
|
||||
emailsGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Loading materials");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error loading materials");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SewingDresses/FormEmails.resx
Normal file
60
SewingDresses/FormEmails.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
23
SewingDresses/FormMain.Designer.cs
generated
23
SewingDresses/FormMain.Designer.cs
generated
@ -33,6 +33,7 @@
|
||||
materialsToolStripMenuItem = new ToolStripMenuItem();
|
||||
dressesToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
employeesToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
materialsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
materialsByDressesToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -42,7 +43,7 @@
|
||||
createOrderButton = new Button();
|
||||
givenOrderButton = new Button();
|
||||
refreshOrdersButton = new Button();
|
||||
employeesToolStripMenuItem = new ToolStripMenuItem();
|
||||
emailsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -58,7 +59,7 @@
|
||||
//
|
||||
// directoriesToolStripMenuItem
|
||||
//
|
||||
directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { materialsToolStripMenuItem, dressesToolStripMenuItem, clientsToolStripMenuItem, employeesToolStripMenuItem });
|
||||
directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { materialsToolStripMenuItem, dressesToolStripMenuItem, clientsToolStripMenuItem, employeesToolStripMenuItem, emailsToolStripMenuItem });
|
||||
directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
|
||||
directoriesToolStripMenuItem.Size = new Size(75, 20);
|
||||
directoriesToolStripMenuItem.Text = "Directories";
|
||||
@ -84,6 +85,13 @@
|
||||
clientsToolStripMenuItem.Text = "Clients";
|
||||
clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
|
||||
//
|
||||
// employeesToolStripMenuItem
|
||||
//
|
||||
employeesToolStripMenuItem.Name = "employeesToolStripMenuItem";
|
||||
employeesToolStripMenuItem.Size = new Size(180, 22);
|
||||
employeesToolStripMenuItem.Text = "Employees";
|
||||
employeesToolStripMenuItem.Click += employeesToolStripMenuItem_Click;
|
||||
//
|
||||
// reportsToolStripMenuItem
|
||||
//
|
||||
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { materialsListToolStripMenuItem, materialsByDressesToolStripMenuItem, ordersListToolStripMenuItem });
|
||||
@ -159,12 +167,12 @@
|
||||
refreshOrdersButton.UseVisualStyleBackColor = true;
|
||||
refreshOrdersButton.Click += ButtonRef_Click;
|
||||
//
|
||||
// employeesToolStripMenuItem
|
||||
// emailsToolStripMenuItem
|
||||
//
|
||||
employeesToolStripMenuItem.Name = "employeesToolStripMenuItem";
|
||||
employeesToolStripMenuItem.Size = new Size(180, 22);
|
||||
employeesToolStripMenuItem.Text = "Employees";
|
||||
employeesToolStripMenuItem.Click += employeesToolStripMenuItem_Click;
|
||||
emailsToolStripMenuItem.Name = "emailsToolStripMenuItem";
|
||||
emailsToolStripMenuItem.Size = new Size(180, 22);
|
||||
emailsToolStripMenuItem.Text = "Emails";
|
||||
emailsToolStripMenuItem.Click += emailsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
@ -204,5 +212,6 @@
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
private ToolStripMenuItem startWorkingToolStripMenuItem;
|
||||
private ToolStripMenuItem employeesToolStripMenuItem;
|
||||
private ToolStripMenuItem emailsToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -177,5 +177,14 @@ namespace SewingDresses
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void emailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormEmails));
|
||||
if (service is FormEmails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace SewingDresses
|
||||
Login = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
Password = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClient Port"]),
|
||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||
});
|
||||
@ -96,6 +96,7 @@ namespace SewingDresses
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormEmployees>();
|
||||
services.AddTransient<FormEmployee>();
|
||||
services.AddTransient<FormEmails>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailEmployee>()?.MailCheck();
|
||||
|
Loading…
Reference in New Issue
Block a user