Compare commits
2 Commits
da14365aa4
...
f8a5483125
Author | SHA1 | Date | |
---|---|---|---|
f8a5483125 | |||
0f00df1b95 |
@ -1,6 +1,8 @@
|
|||||||
using RenovationWorkContracts.BindingModels;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RenovationWorkContracts.BindingModels;
|
||||||
using RenovationWorkContracts.BusinessLogicsContracts;
|
using RenovationWorkContracts.BusinessLogicsContracts;
|
||||||
using RenovationWorkContracts.SeatchModels;
|
using RenovationWorkContracts.SeatchModels;
|
||||||
|
using RenovationWorkContracts.StorageContracts;
|
||||||
using RenovationWorkContracts.ViewModels;
|
using RenovationWorkContracts.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -12,29 +14,107 @@ namespace RenovationWorkBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
public class ClientLogic : IClientLogic //дописать
|
public class ClientLogic : IClientLogic //дописать
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
public bool Create(ClientBindingModel model)
|
public bool Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(ClientBindingModel model)
|
public bool Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_clientStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ClientFIO:{ClientFIO}. Id:{ Id}", model.ClientFIO, model.Id);
|
||||||
|
var element = _clientStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_logger.LogInformation("ReadList. ClientFIO:{ClientFIO}. Id:{Id}", model?.ClientFIO, model?.Id);
|
||||||
|
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(ClientBindingModel model)
|
public bool Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||||
|
{
|
||||||
|
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.Email));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Client. ClientID:{Id}. ClientFIO: {ClientFIO}. Email:{ Email}. Password: { Password}", model.Id, model.ClientFIO, model.Email, model.Password);
|
||||||
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Email = model.Email
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Такой клиент уже существует");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,12 @@
|
|||||||
|
using RenovationWorkClientApp;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
@ -13,7 +15,7 @@ if (!app.Environment.IsDevelopment())
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
@ -14,4 +14,6 @@
|
|||||||
<ProjectReference Include="..\RenovationWorkContracts\RenovationWorkContracts.csproj" />
|
<ProjectReference Include="..\RenovationWorkContracts\RenovationWorkContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Изделие:</div>
|
<div class="col-4">Изделие:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
|
<select id="Repair" name="Repair" class="form-control" asp-items="@(new SelectList(@ViewBag.Repairs,"Id", "RepairName"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#product').on('change', function () {
|
$('#Repair').on('change', function () {
|
||||||
check();
|
check();
|
||||||
});
|
});
|
||||||
$('#count').on('change', function () {
|
$('#count').on('change', function () {
|
||||||
@ -35,12 +35,12 @@
|
|||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
var count = $('#count').val();
|
var count = $('#count').val();
|
||||||
var product = $('#product').val();
|
var Repair = $('#Repair').val();
|
||||||
if (count && product) {
|
if (count && Repair) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/Home/Calc",
|
url: "/Home/Calc",
|
||||||
data: { count: count, product: product },
|
data: { count: count, Repair: Repair },
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
$("#sum").val(result);
|
$("#sum").val(result);
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"IPAddress": "http://localhost:28379/"
|
"IPAddress": "http://localhost:5127/"
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,6 @@ namespace RenovationWorkContracts.BindingModels
|
|||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,13 @@ namespace RenovationWorkContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
|
public int ClientId { get; set; }
|
||||||
public int RepairId { get; set; }
|
public int RepairId { get; set; }
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Ремонт")]
|
[DisplayName("Ремонт")]
|
||||||
public string RepairName { get; set; } = string.Empty;
|
public string RepairName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
@ -26,5 +28,9 @@ namespace RenovationWorkContracts.ViewModels
|
|||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Дата выполнения")]
|
[DisplayName("Дата выполнения")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Фамилия клиента")]
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using RenovationWorkContracts.SeatchModels;
|
using RenovationWorkContracts.SeatchModels;
|
||||||
using RenovationWorkContracts.StorageContracts;
|
using RenovationWorkContracts.StorageContracts;
|
||||||
using RenovationWorkContracts.ViewModels;
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkDatabaseImplement.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,32 +15,78 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
var res = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
context.Clients.Remove(res);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
return context.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
if (model.Email != null && model.Password != null)
|
||||||
|
return context.Clients
|
||||||
|
.FirstOrDefault(x => x.Email.Equals(model.Email)
|
||||||
|
&& x.Password.Equals(model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
if (model.Email != null)
|
||||||
|
return context.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
if (model.Email != null)
|
||||||
|
{
|
||||||
|
using var context = new RenovationWorkDatabase();
|
||||||
|
return context.Clients
|
||||||
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFullList()
|
public List<ClientViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
return context.Clients.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
var res = Client.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
context.Clients.Add(res);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Update(ClientBindingModel model)
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
var res = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
res?.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,29 +40,58 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
|
|
||||||
using var context = new RenovationWorkDatabase();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
|
||||||
return GetViewModel(context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
return context.Orders
|
||||||
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
using var context = new RenovationWorkDatabase();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
using var context = new RenovationWorkDatabase();
|
|
||||||
|
|
||||||
return context.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).ToList();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
using var context = new RenovationWorkDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Repair)
|
.Include(x => x.Repair)
|
||||||
.Select(x => x.GetViewModel)
|
.Include(x => x.Client)
|
||||||
.ToList();
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -77,24 +106,30 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
|
|
||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return GetViewModel(newOrder);
|
return context.Orders
|
||||||
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
|
||||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var order = context.Orders.Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
return context.Orders
|
||||||
return GetViewModel(order);
|
.Include(x => x.Repair)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OrderViewModel GetViewModel(Order order)
|
private static OrderViewModel GetViewModel(Order order)
|
||||||
|
212
RenovationWork/RenovationWorkDatabaseImplement/Migrations/20230424141242_Second.Designer.cs
generated
Normal file
212
RenovationWork/RenovationWorkDatabaseImplement/Migrations/20230424141242_Second.Designer.cs
generated
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using RenovationWorkDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RenovationWorkDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(RenovationWorkDatabase))]
|
||||||
|
[Migration("20230424141242_Second")]
|
||||||
|
partial class Second
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.4")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.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("RenovationWorkDatabaseImplement.Model.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("RenovationWorkDatabaseImplement.Model.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("RepairId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Repair", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("RepairName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Repairs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.RepairComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("RepairId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
|
b.ToTable("RepairComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Repair", "Repair")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RepairId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Repair");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.RepairComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Component", "Component")
|
||||||
|
.WithMany("RepairComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Repair", "Repair")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("RepairId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Repair");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("RepairComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Repair", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RenovationWorkDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Second : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Clients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
ClientFIO = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_RepairId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "RepairId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Orders_Clients_ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Orders_Repairs_RepairId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "RepairId",
|
||||||
|
principalTable: "Repairs",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Orders_Clients_ClientId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Orders_Repairs_RepairId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Orders_ClientId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Orders_RepairId",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ClientId",
|
||||||
|
table: "Orders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,31 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.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("RenovationWorkDatabaseImplement.Model.Component", b =>
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Component", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -50,6 +75,9 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Count")
|
b.Property<int>("Count")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@ -70,6 +98,10 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("RepairId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -119,6 +151,25 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
b.ToTable("RepairComponents");
|
b.ToTable("RepairComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Repair", "Repair")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RepairId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Repair");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.RepairComponent", b =>
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.RepairComponent", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("RenovationWorkDatabaseImplement.Model.Component", "Component")
|
b.HasOne("RenovationWorkDatabaseImplement.Model.Component", "Component")
|
||||||
@ -138,6 +189,11 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
b.Navigation("Repair");
|
b.Navigation("Repair");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Component", b =>
|
modelBuilder.Entity("RenovationWorkDatabaseImplement.Model.Component", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("RepairComponents");
|
b.Navigation("RepairComponents");
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
using RenovationWorkContracts.BindingModels;
|
||||||
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RenovationWorkDatabaseImplement.Model
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ using RenovationWorkContracts.ViewModels;
|
|||||||
using RenovationWorkDataModels.Enums;
|
using RenovationWorkDataModels.Enums;
|
||||||
using RenovationWorkDataModels.Models;
|
using RenovationWorkDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -16,6 +17,8 @@ namespace RenovationWorkDatabaseImplement.Model
|
|||||||
[Required]
|
[Required]
|
||||||
public int RepairId { get; set; }
|
public int RepairId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
@ -25,10 +28,9 @@ namespace RenovationWorkDatabaseImplement.Model
|
|||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
public virtual Repair Repair { get; set; }
|
||||||
|
public virtual Client Client { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public virtual Repair Repair { get; set; } = new();
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -39,6 +41,7 @@ namespace RenovationWorkDatabaseImplement.Model
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
RepairId = model.RepairId,
|
RepairId = model.RepairId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -61,12 +64,14 @@ namespace RenovationWorkDatabaseImplement.Model
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
RepairId = RepairId,
|
RepairId = RepairId,
|
||||||
|
ClientId = ClientId,
|
||||||
|
ClientFIO = Client.ClientFIO,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
RepairName = Repair.RepairName,
|
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement
|
DateImplement = DateImplement,
|
||||||
|
RepairName = Repair.RepairName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,6 @@ namespace RenovationWorkDatabaseImplement
|
|||||||
public virtual DbSet<RepairComponent> RepairComponents { set; get; }
|
public virtual DbSet<RepairComponent> RepairComponents { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace RenovationWorkFileImplement
|
|||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
|
|
||||||
private readonly string RepairFileName = "Repair.xml";
|
private readonly string RepairFileName = "Repair.xml";
|
||||||
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
public List<Client> Clients { get; private set; }
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
@ -40,12 +42,15 @@ namespace RenovationWorkFileImplement
|
|||||||
public void SaveRepairs() => SaveData(Repairs, RepairFileName, "Repairs", x => x.GetXElement);
|
public void SaveRepairs() => SaveData(Repairs, RepairFileName, "Repairs", x => x.GetXElement);
|
||||||
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
|
||||||
|
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Repairs = LoadData(RepairFileName, "Repair", x => Repair.Create(x)!)!;
|
Repairs = LoadData(RepairFileName, "Repair", x => Repair.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using RenovationWorkContracts.SeatchModels;
|
using RenovationWorkContracts.SeatchModels;
|
||||||
using RenovationWorkContracts.StorageContracts;
|
using RenovationWorkContracts.StorageContracts;
|
||||||
using RenovationWorkContracts.ViewModels;
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkFileImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,34 +13,84 @@ namespace RenovationWorkFileImplement.Implements
|
|||||||
{
|
{
|
||||||
public class ClientStorage : IClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Clients.Remove(res);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model.Id.HasValue)
|
||||||
|
return _source.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
if (model.Email != null && model.Password != null)
|
||||||
|
return _source.Clients
|
||||||
|
.FirstOrDefault(x => x.Email.Equals(model.Email)
|
||||||
|
&& x.Password.Equals(model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
if (model.Email != null)
|
||||||
|
return _source.Clients.FirstOrDefault(x => x.Email.Equals(model.Email))?.GetViewModel;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
|
}
|
||||||
|
if (model.Email != null)
|
||||||
|
{
|
||||||
|
return _source.Clients
|
||||||
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFullList()
|
public List<ClientViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _source.Clients.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
model.Id = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.Id) + 1 : 1;
|
||||||
|
var res = Client.Create(model);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
_source.Clients.Add(res);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Update(ClientBindingModel model)
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Update(model);
|
||||||
|
_source.SaveClients();
|
||||||
|
}
|
||||||
|
return res?.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,22 @@ namespace RenovationWorkFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return source.Orders
|
||||||
|
.Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => GetViewModel(x))
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
return source.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).ToList();
|
if (!model.Id.HasValue && model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => GetViewModel(x))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
var result = GetElement(model);
|
||||||
|
return result != null ? new() { result } : new();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +104,14 @@ namespace RenovationWorkFileImplement.Implements
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach (var client in source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == order.ClientId)
|
||||||
|
{
|
||||||
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
78
RenovationWork/RenovationWorkFileImplement/Models/Client.cs
Normal file
78
RenovationWork/RenovationWorkFileImplement/Models/Client.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using RenovationWorkContracts.BindingModels;
|
||||||
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace RenovationWorkFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Client? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ClientFIO = element.Element("FIO")!.Value,
|
||||||
|
Email = element.Element("Email")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Client",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("FIO", ClientFIO),
|
||||||
|
new XElement("Email", Email),
|
||||||
|
new XElement("Password", Password)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ namespace RenovationWorkFileImplement.Models
|
|||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
@ -41,6 +42,7 @@ namespace RenovationWorkFileImplement.Models
|
|||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
|
ClientId = model.ClientId,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement
|
DateImplement = model.DateImplement
|
||||||
};
|
};
|
||||||
@ -56,6 +58,7 @@ namespace RenovationWorkFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
RepairId = Convert.ToInt32(element.Element("RepairId")!.Value),
|
RepairId = Convert.ToInt32(element.Element("RepairId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
|
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
|
||||||
};
|
};
|
||||||
@ -87,6 +90,7 @@ namespace RenovationWorkFileImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
RepairId = RepairId,
|
RepairId = RepairId,
|
||||||
RepairName = RepairName,
|
RepairName = RepairName,
|
||||||
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
@ -97,6 +101,7 @@ namespace RenovationWorkFileImplement.Models
|
|||||||
public XElement GetXElement => new("Order",
|
public XElement GetXElement => new("Order",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("RepairId", RepairId),
|
new XElement("RepairId", RepairId),
|
||||||
|
new XElement("ClientId", ClientId),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using RenovationWorkListImplement.Models;
|
using RenovationWorkListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -10,27 +11,23 @@ namespace RenovationWorkListImplement
|
|||||||
public class DataListSingleton
|
public class DataListSingleton
|
||||||
{
|
{
|
||||||
private static DataListSingleton? _instance;
|
private static DataListSingleton? _instance;
|
||||||
|
|
||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
|
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
|
|
||||||
public List<Repair> Repair { get; set; }
|
public List<Repair> Repair { get; set; }
|
||||||
|
public List<Client> Clients { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Repair = new List<Repair>();
|
Repair = new List<Repair>();
|
||||||
|
Clients = new List<Client>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
_instance = new DataListSingleton();
|
_instance = new DataListSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using RenovationWorkContracts.SeatchModels;
|
using RenovationWorkContracts.SeatchModels;
|
||||||
using RenovationWorkContracts.StorageContracts;
|
using RenovationWorkContracts.StorageContracts;
|
||||||
using RenovationWorkContracts.ViewModels;
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,34 +13,108 @@ namespace RenovationWorkListImplement.Implements
|
|||||||
{
|
{
|
||||||
public class ClientStorage : IClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
for (int i = 0; i < _source.Clients.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Clients[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Clients[i];
|
||||||
|
_source.Clients.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == model.Id)
|
||||||
|
{
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Email == model.Email && client.Password == model.Password)
|
||||||
|
{
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var result = new List<ClientViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Email.Contains(model.Email))
|
||||||
|
{
|
||||||
|
result.Add(client.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFullList()
|
public List<ClientViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var result = new List<ClientViewModel>();
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
result.Add(client.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
model.Id = 1;
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (model.Id <= client.Id)
|
||||||
|
{
|
||||||
|
model.Id = client.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Clients.Add(newClient);
|
||||||
|
return newClient.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Update(ClientBindingModel model)
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == model.Id)
|
||||||
|
{
|
||||||
|
client.Update(model);
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
RenovationWork/RenovationWorkListImplement/Models/Client.cs
Normal file
50
RenovationWork/RenovationWorkListImplement/Models/Client.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using RenovationWorkContracts.BindingModels;
|
||||||
|
using RenovationWorkContracts.ViewModels;
|
||||||
|
using RenovationWorkDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RenovationWorkListImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public static Client? Create(ClientBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Client()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ClientBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ namespace RenovationWorkListImplement.Models
|
|||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ namespace RenovationWorkListImplement.Models
|
|||||||
RepairName = model.RepairName,
|
RepairName = model.RepairName,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement
|
DateImplement = model.DateImplement
|
||||||
@ -56,6 +58,7 @@ namespace RenovationWorkListImplement.Models
|
|||||||
RepairName = model.RepairName;
|
RepairName = model.RepairName;
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
|
ClientId = model.ClientId;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
@ -67,6 +70,7 @@ namespace RenovationWorkListImplement.Models
|
|||||||
RepairId = RepairId,
|
RepairId = RepairId,
|
||||||
RepairName = RepairName,
|
RepairName = RepairName,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
|
ClientId = ClientId,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
@ -23,7 +23,7 @@ builder.Services.AddControllers();
|
|||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen(c =>
|
||||||
{
|
{
|
||||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "AbstractShopRestApi", Version = "v1" });
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "RenovationWorkRestApi", Version = "v1" });
|
||||||
});
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
@ -32,7 +32,7 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbstractShopRestApi v1"));
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "RenovationWorkRestApi v1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
this.SumTextBox = new System.Windows.Forms.TextBox();
|
this.SumTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
this.SaveButton = new System.Windows.Forms.Button();
|
this.SaveButton = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxClient = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelClients = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// RepairNameLabel
|
// RepairNameLabel
|
||||||
@ -96,7 +98,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonCancel
|
// ButtonCancel
|
||||||
//
|
//
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(250, 151);
|
this.ButtonCancel.Location = new System.Drawing.Point(246, 186);
|
||||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
||||||
@ -107,7 +109,7 @@
|
|||||||
//
|
//
|
||||||
// SaveButton
|
// SaveButton
|
||||||
//
|
//
|
||||||
this.SaveButton.Location = new System.Drawing.Point(158, 151);
|
this.SaveButton.Location = new System.Drawing.Point(154, 186);
|
||||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.SaveButton.Name = "SaveButton";
|
this.SaveButton.Name = "SaveButton";
|
||||||
this.SaveButton.Size = new System.Drawing.Size(86, 31);
|
this.SaveButton.Size = new System.Drawing.Size(86, 31);
|
||||||
@ -116,11 +118,31 @@
|
|||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
this.SaveButton.UseVisualStyleBackColor = true;
|
||||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||||
//
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
this.comboBoxClient.FormattingEnabled = true;
|
||||||
|
this.comboBoxClient.Location = new System.Drawing.Point(106, 136);
|
||||||
|
this.comboBoxClient.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.comboBoxClient.Name = "comboBoxClient";
|
||||||
|
this.comboBoxClient.Size = new System.Drawing.Size(226, 28);
|
||||||
|
this.comboBoxClient.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// labelClients
|
||||||
|
//
|
||||||
|
this.labelClients.AutoSize = true;
|
||||||
|
this.labelClients.Location = new System.Drawing.Point(15, 139);
|
||||||
|
this.labelClients.Name = "labelClients";
|
||||||
|
this.labelClients.Size = new System.Drawing.Size(61, 20);
|
||||||
|
this.labelClients.TabIndex = 11;
|
||||||
|
this.labelClients.Text = "Клиент:";
|
||||||
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(353, 204);
|
this.ClientSize = new System.Drawing.Size(399, 327);
|
||||||
|
this.Controls.Add(this.labelClients);
|
||||||
|
this.Controls.Add(this.comboBoxClient);
|
||||||
this.Controls.Add(this.SaveButton);
|
this.Controls.Add(this.SaveButton);
|
||||||
this.Controls.Add(this.ButtonCancel);
|
this.Controls.Add(this.ButtonCancel);
|
||||||
this.Controls.Add(this.SumTextBox);
|
this.Controls.Add(this.SumTextBox);
|
||||||
@ -147,5 +169,7 @@
|
|||||||
private TextBox SumTextBox;
|
private TextBox SumTextBox;
|
||||||
private Button ButtonCancel;
|
private Button ButtonCancel;
|
||||||
private Button SaveButton;
|
private Button SaveButton;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
|
private Label labelClients;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RenovationWorkBusinessLogic.BusinessLogic;
|
||||||
using RenovationWorkContracts.BindingModels;
|
using RenovationWorkContracts.BindingModels;
|
||||||
using RenovationWorkContracts.BusinessLogicsContracts;
|
using RenovationWorkContracts.BusinessLogicsContracts;
|
||||||
using RenovationWorkContracts.SeatchModels;
|
using RenovationWorkContracts.SeatchModels;
|
||||||
@ -19,13 +20,16 @@ namespace PrecastConcretePlantView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IRepairLogic _logicP;
|
private readonly IRepairLogic _logicP;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IRepairLogic logicP, IOrderLogic logicO)
|
|
||||||
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IRepairLogic logicP, IOrderLogic logicO, IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +47,14 @@ namespace PrecastConcretePlantView
|
|||||||
RepairComboBox.DataSource = list;
|
RepairComboBox.DataSource = list;
|
||||||
RepairComboBox.SelectedItem = null;
|
RepairComboBox.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
var clients = _clientLogic.ReadList(null);
|
||||||
|
if (clients != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "ClientFIO";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = clients;
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -110,6 +122,7 @@ namespace PrecastConcretePlantView
|
|||||||
RepairId = Convert.ToInt32(RepairComboBox.SelectedValue),
|
RepairId = Convert.ToInt32(RepairComboBox.SelectedValue),
|
||||||
RepairName = RepairComboBox.Text,
|
RepairName = RepairComboBox.Text,
|
||||||
Count = Convert.ToInt32(CountTextBox.Text),
|
Count = Convert.ToInt32(CountTextBox.Text),
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||||
Sum = Convert.ToDouble(SumTextBox.Text)
|
Sum = Convert.ToDouble(SumTextBox.Text)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.КлиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.componentProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.componentProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
@ -63,7 +64,8 @@
|
|||||||
//
|
//
|
||||||
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ИзделияToolStripMenuItem,
|
this.ИзделияToolStripMenuItem,
|
||||||
this.КомпонентыToolStripMenuItem});
|
this.КомпонентыToolStripMenuItem,
|
||||||
|
this.КлиентыToolStripMenuItem});
|
||||||
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||||
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
||||||
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||||
@ -71,17 +73,24 @@
|
|||||||
// ИзделияToolStripMenuItem
|
// ИзделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||||
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.ИзделияToolStripMenuItem.Text = "Изделия";
|
this.ИзделияToolStripMenuItem.Text = "Изделия";
|
||||||
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// КомпонентыToolStripMenuItem
|
// КомпонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// КлиентыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.КлиентыToolStripMenuItem.Name = "КлиентыToolStripMenuItem";
|
||||||
|
this.КлиентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||||
|
this.КлиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
|
this.КлиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@ -231,5 +240,6 @@
|
|||||||
private ToolStripMenuItem componentsToolStripMenuItem;
|
private ToolStripMenuItem componentsToolStripMenuItem;
|
||||||
private ToolStripMenuItem componentProductsToolStripMenuItem;
|
private ToolStripMenuItem componentProductsToolStripMenuItem;
|
||||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,6 +50,8 @@ namespace PrecastConcretePlantView
|
|||||||
{
|
{
|
||||||
DataGridView.DataSource = list;
|
DataGridView.DataSource = list;
|
||||||
DataGridView.Columns["RepairId"].Visible = false;
|
DataGridView.Columns["RepairId"].Visible = false;
|
||||||
|
DataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
@ -91,6 +93,14 @@ namespace PrecastConcretePlantView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||||
|
if (service is FormClients form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
|
private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user