Compare commits
No commits in common. "f8a548312551cfea899b1bed6f584e90a46dba5b" and "da14365aa4dcf99ff4d55cbf784ef3b953449a9c" have entirely different histories.
f8a5483125
...
da14365aa4
@ -1,8 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using RenovationWorkContracts.BindingModels;
|
||||||
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;
|
||||||
@ -14,107 +12,29 @@ 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)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
throw new NotImplementedException();
|
||||||
if (_clientStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(ClientBindingModel model)
|
public bool Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
throw new NotImplementedException();
|
||||||
_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)
|
||||||
{
|
{
|
||||||
if (model == null)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ClientFIO:{ClientFIO}. Id:{Id}", model?.ClientFIO, model?.Id);
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
throw new NotImplementedException();
|
||||||
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,12 +1,10 @@
|
|||||||
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())
|
||||||
{
|
{
|
||||||
@ -15,7 +13,7 @@ if (!app.Environment.IsDevelopment())
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
@ -14,6 +14,4 @@
|
|||||||
<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="Repair" name="Repair" class="form-control" asp-items="@(new SelectList(@ViewBag.Repairs,"Id", "RepairName"))"></select>
|
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#Repair').on('change', function () {
|
$('#product').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 Repair = $('#Repair').val();
|
var product = $('#product').val();
|
||||||
if (count && Repair) {
|
if (count && product) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/Home/Calc",
|
url: "/Home/Calc",
|
||||||
data: { count: count, Repair: Repair },
|
data: { count: count, product: product },
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
$("#sum").val(result);
|
$("#sum").val(result);
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"IPAddress": "http://localhost:5127/"
|
"IPAddress": "http://localhost:28379/"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,5 @@ 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,13 +11,11 @@ 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("Сумма")]
|
||||||
@ -28,9 +26,5 @@ 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,7 +2,6 @@
|
|||||||
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;
|
||||||
@ -15,78 +14,32 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public ClientViewModel? Delete(ClientBindingModel model)
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (model == null)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
throw new NotImplementedException();
|
||||||
return context.Clients.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
throw new NotImplementedException();
|
||||||
var res = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
res?.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return res?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,58 +40,29 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
|
|
||||||
using var context = new RenovationWorkDatabase();
|
using var context = new RenovationWorkDatabase();
|
||||||
|
|
||||||
return context.Orders
|
return GetViewModel(context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||||
.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)
|
||||||
{
|
{
|
||||||
using var context = new RenovationWorkDatabase();
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||||
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)
|
||||||
.Include(x => x.Client)
|
.Select(x => x.GetViewModel)
|
||||||
.Select(x => x.GetViewModel)
|
.ToList();
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -106,30 +77,24 @@ namespace RenovationWorkDatabaseImplement.Implements
|
|||||||
|
|
||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return GetViewModel(newOrder);
|
||||||
.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.Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id);
|
var order = context.Orders.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
|
|
||||||
.Include(x => x.Repair)
|
return GetViewModel(order);
|
||||||
.Include(x => x.Client)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OrderViewModel GetViewModel(Order order)
|
private static OrderViewModel GetViewModel(Order order)
|
||||||
|
@ -1,212 +0,0 @@
|
|||||||
// <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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
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,31 +22,6 @@ 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")
|
||||||
@ -75,9 +50,6 @@ 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");
|
||||||
|
|
||||||
@ -98,10 +70,6 @@ namespace RenovationWorkDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("RepairId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -151,25 +119,6 @@ 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")
|
||||||
@ -189,11 +138,6 @@ 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");
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
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,7 +3,6 @@ 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;
|
||||||
@ -17,8 +16,6 @@ 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; }
|
||||||
@ -28,9 +25,10 @@ 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)
|
||||||
@ -41,7 +39,6 @@ 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,
|
||||||
@ -64,14 +61,12 @@ 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,6 +32,5 @@ 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,8 +19,6 @@ 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; }
|
||||||
|
|
||||||
|
|
||||||
@ -42,15 +40,12 @@ 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,7 +2,6 @@
|
|||||||
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;
|
||||||
@ -13,84 +12,34 @@ 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)
|
||||||
{
|
{
|
||||||
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
throw new NotImplementedException();
|
||||||
if (res != null)
|
|
||||||
{
|
|
||||||
_source.Clients.Remove(res);
|
|
||||||
_source.SaveClients();
|
|
||||||
}
|
|
||||||
return res?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue)
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (model == null)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
return _source.Clients.Select(x => x.GetViewModel).ToList();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.Id) + 1 : 1;
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
var res = _source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
throw new NotImplementedException();
|
||||||
if (res != null)
|
|
||||||
{
|
|
||||||
res.Update(model);
|
|
||||||
_source.SaveClients();
|
|
||||||
}
|
|
||||||
return res?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,22 +32,11 @@ 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 source.Orders
|
return new();
|
||||||
.Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo)
|
|
||||||
.Select(x => GetViewModel(x))
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
if (!model.Id.HasValue && model.ClientId.HasValue)
|
return source.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).ToList();
|
||||||
{
|
|
||||||
return source.Orders
|
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
|
||||||
.Select(x => GetViewModel(x))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
var result = GetElement(model);
|
|
||||||
return result != null ? new() { result } : new();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,14 +93,6 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
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,7 +26,6 @@ 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)
|
||||||
{
|
{
|
||||||
@ -42,7 +41,6 @@ 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
|
||||||
};
|
};
|
||||||
@ -58,7 +56,6 @@ 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),
|
||||||
};
|
};
|
||||||
@ -90,7 +87,6 @@ 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,
|
||||||
@ -101,7 +97,6 @@ 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,6 +1,5 @@
|
|||||||
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;
|
||||||
@ -11,23 +10,27 @@ 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,7 +2,6 @@
|
|||||||
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;
|
||||||
@ -13,108 +12,34 @@ 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)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _source.Clients.Count; ++i)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var result = new List<ClientViewModel>();
|
throw new NotImplementedException();
|
||||||
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()
|
||||||
{
|
{
|
||||||
var result = new List<ClientViewModel>();
|
throw new NotImplementedException();
|
||||||
foreach (var client in _source.Clients)
|
|
||||||
{
|
|
||||||
result.Add(client.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = 1;
|
throw new NotImplementedException();
|
||||||
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)
|
||||||
{
|
{
|
||||||
foreach (var client in _source.Clients)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
if (client.Id == model.Id)
|
|
||||||
{
|
|
||||||
client.Update(model);
|
|
||||||
return client.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
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,7 +18,6 @@ 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.Неизвестен;
|
||||||
|
|
||||||
@ -41,7 +40,6 @@ 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
|
||||||
@ -58,7 +56,6 @@ 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;
|
||||||
@ -70,7 +67,6 @@ 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 = "RenovationWorkRestApi", Version = "v1" });
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "AbstractShopRestApi", 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", "RenovationWorkRestApi v1"));
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbstractShopRestApi v1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
@ -36,8 +36,6 @@
|
|||||||
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
|
||||||
@ -98,7 +96,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonCancel
|
// ButtonCancel
|
||||||
//
|
//
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(246, 186);
|
this.ButtonCancel.Location = new System.Drawing.Point(250, 151);
|
||||||
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);
|
||||||
@ -109,7 +107,7 @@
|
|||||||
//
|
//
|
||||||
// SaveButton
|
// SaveButton
|
||||||
//
|
//
|
||||||
this.SaveButton.Location = new System.Drawing.Point(154, 186);
|
this.SaveButton.Location = new System.Drawing.Point(158, 151);
|
||||||
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);
|
||||||
@ -118,31 +116,11 @@
|
|||||||
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(399, 327);
|
this.ClientSize = new System.Drawing.Size(353, 204);
|
||||||
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);
|
||||||
@ -169,7 +147,5 @@
|
|||||||
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,7 +8,6 @@ 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;
|
||||||
@ -20,16 +19,13 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,14 +43,6 @@ 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)
|
||||||
@ -122,7 +110,6 @@ 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,7 +32,6 @@
|
|||||||
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();
|
||||||
@ -64,8 +63,7 @@
|
|||||||
//
|
//
|
||||||
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правочники";
|
||||||
@ -73,24 +71,17 @@
|
|||||||
// ИзделияToolStripMenuItem
|
// ИзделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||||
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(182, 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(224, 26);
|
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 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[] {
|
||||||
@ -240,6 +231,5 @@
|
|||||||
private ToolStripMenuItem componentsToolStripMenuItem;
|
private ToolStripMenuItem componentsToolStripMenuItem;
|
||||||
private ToolStripMenuItem componentProductsToolStripMenuItem;
|
private ToolStripMenuItem componentProductsToolStripMenuItem;
|
||||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,8 +50,6 @@ 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("Загрузка заказов");
|
||||||
@ -93,14 +91,6 @@ 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