Changes some files
This commit is contained in:
parent
3db1002d0f
commit
63ba7d1a44
@ -95,6 +95,7 @@ namespace SushiBar
|
|||||||
services.AddTransient<FormImplementers>();
|
services.AddTransient<FormImplementers>();
|
||||||
services.AddTransient<FormImplementer>();
|
services.AddTransient<FormImplementer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -106,8 +106,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
model.Status = status;
|
model.Status = status;
|
||||||
model.DateCreate = order.DateCreate;
|
model.DateCreate = order.DateCreate;
|
||||||
if (model.DateImplement == null)
|
model.DateImplement ??= order.DateImplement;
|
||||||
model.DateImplement = order.DateImplement;
|
|
||||||
if (order.ImplementerId.HasValue)
|
if (order.ImplementerId.HasValue)
|
||||||
model.ImplementerId = order.ImplementerId;
|
model.ImplementerId = order.ImplementerId;
|
||||||
if (model.Status == OrderStatus.Issued)
|
if (model.Status == OrderStatus.Issued)
|
||||||
@ -118,11 +117,16 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
|||||||
model.SushiId = order.SushiId;
|
model.SushiId = order.SushiId;
|
||||||
model.Sum = order.Sum;
|
model.Sum = order.Sum;
|
||||||
model.Count = order.Count;
|
model.Count = order.Count;
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
|
var result = _orderStorage.Update(model);
|
||||||
|
if (result == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SendOrderMessage(result.ClientId,
|
||||||
|
$"Sushi Bar, Order №{result.Id}",
|
||||||
|
$"Order №{model.Id} changed status on {result.Status}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,5 +149,15 @@ namespace SushiBarClientApi.Controllers
|
|||||||
var prod = APIClient.GetRequest<SushiViewModel>($"api/Main/GetProduct?sushiId={sushi}");
|
var prod = APIClient.GetRequest<SushiViewModel>($"api/Main/GetProduct?sushiId={sushi}");
|
||||||
return count * (prod?.Price ?? 1);
|
return count * (prod?.Price ?? 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Mails()
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/GetMessages?clientId={APIClient.Client.Id}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
50
SushiBar/SushiBarClientApi/Views/Home/Mails.cshtml
Normal file
50
SushiBar/SushiBarClientApi/Views/Home/Mails.cshtml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
@model List<SushiBarContracts.ViewModels.MessageInfoViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Mails";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заказы</h1>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Дата письма
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Заголовок
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Текст
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem =>
|
||||||
|
item.DateDelivery)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem =>
|
||||||
|
item.Subject)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem =>
|
||||||
|
item.Body)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
@ -23,13 +23,16 @@
|
|||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Orders</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Orders</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">My info</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">PM</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Sign in</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Mails</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Sign up</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Sign In</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Sing Up</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,9 +12,14 @@ public class ClientController : Controller
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IClientLogic _logic;
|
private readonly IClientLogic _logic;
|
||||||
public ClientController(IClientLogic logic, ILogger<ClientController> logger)
|
private readonly IMessageInfoLogic _mailLogic;
|
||||||
|
|
||||||
|
public ClientController(IClientLogic logic,
|
||||||
|
ILogger<ClientController> logger,
|
||||||
|
IMessageInfoLogic mailLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_mailLogic = mailLogic;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,4 +68,20 @@ public class ClientController : Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
ClientId = clientId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,6 +3,8 @@ using SushiBarContracts.BusinessLogicsContracts;
|
|||||||
using SushiBarContracts.StoragesContracts;
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarDatabaseImplement.Implements;
|
using SushiBarDatabaseImplement.Implements;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using SushiBarBusinessLogic.MailWorker;
|
||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -14,10 +16,14 @@ builder.Logging.AddLog4Net("log4net.config");
|
|||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<ISushiStorage, SushiStorage>();
|
builder.Services.AddTransient<ISushiStorage, SushiStorage>();
|
||||||
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
builder.Services.AddTransient<IMessageInfoStorage, MessageStorage>();
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
builder.Services.AddTransient<ISushiLogic, SushiLogic>();
|
builder.Services.AddTransient<ISushiLogic, SushiLogic>();
|
||||||
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
@ -26,6 +32,21 @@ builder.Services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title
|
|||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||||
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value
|
||||||
|
?? string.Empty,
|
||||||
|
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value ??
|
||||||
|
string.Empty,
|
||||||
|
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value ??
|
||||||
|
string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value),
|
||||||
|
PopHost = builder.Configuration?.GetSection("PopHost")?.Value ??
|
||||||
|
string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user