Надо пофиксить баг с RequestId

This commit is contained in:
Marselchi 2024-05-29 15:49:29 +04:00
parent d3f9279552
commit cd4d6638d9
13 changed files with 739 additions and 58 deletions

View File

@ -20,5 +20,7 @@ namespace CarCenterContracts.BindingModels
public double Price { get; set; }
public Dictionary<int, IBundlingModel> PresaleBundlings { get; set; } = new();
}
public List<int> RequestIds { get; set; } = new();
}
}

View File

@ -12,7 +12,7 @@ namespace CarCenterContracts.ViewModels
public class RequestViewModel : IRequestModel
{
public int Id { get; set; }
public int PresaleId { get; set; }
public int? PresaleId { get; set; }
[DisplayName("Описание пожелания")]
public string Description { get; set; } = string.Empty;
[DisplayName("Тип пожелания")]

View File

@ -85,7 +85,8 @@ namespace CarCenterDatabaseImplement.Implements
return context.Presales
.Include(x => x.Bundlings)
.ThenInclude(x => x.Bundling)
.FirstOrDefault(x => x.Id == newPresale.Id)
.Include(x => x.Requests)
.FirstOrDefault(x => x.Id == newPresale.Id)
?.GetViewModel;
}

View File

@ -42,12 +42,9 @@ namespace CarCenterDatabaseImplement.Implements
public WorkerViewModel? GetElement(WorkerSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.Id.HasValue)
return context.Workers
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
return null;
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Email)) { return null; }
return context.Workers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)
|| (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password) && x.Email.Equals(model.Email) && x.Password.Equals(model.Password)))?.GetViewModel;
}

View File

@ -0,0 +1,509 @@
// <auto-generated />
using System;
using CarCenterDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240529111244_Test")]
partial class Test
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<int>("TirePackage")
.HasColumnType("integer");
b.Property<int>("ToolKit")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarBrand")
.HasColumnType("integer");
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<int>("FeatureID")
.HasColumnType("integer");
b.Property<int?>("FeatureId")
.HasColumnType("integer");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("OrderId")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<long>("VINnumber")
.HasColumnType("bigint");
b.Property<int>("Year")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FeatureId");
b.HasIndex("OrderId");
b.HasIndex("StorekeeperId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("CarId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("CarId");
b.ToTable("CarBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CabinColor")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DriveType")
.HasColumnType("integer");
b.Property<int>("HelpDevice")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Features");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuyerFCS")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PaymentDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("PaymentStatus")
.HasColumnType("integer");
b.Property<int>("PaymentType")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("PresaleId");
b.ToTable("OrderPresales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DueTill")
.HasColumnType("timestamp without time zone");
b.Property<int>("PresaleStatus")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("PresaleId");
b.ToTable("PresaleBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("PresaleId")
.HasColumnType("integer");
b.Property<int>("RequestType")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PresaleId");
b.ToTable("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Workers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Feature", "Feature")
.WithMany("Cars")
.HasForeignKey("FeatureId");
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Cars")
.HasForeignKey("OrderId");
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
.WithMany("Cars")
.HasForeignKey("StorekeeperId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Feature");
b.Navigation("Order");
b.Navigation("Storekeeper");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("CarBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
.WithMany("Bundlings")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Car");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Worker", "Worker")
.WithMany("Orders")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Presales")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("OrderPresales")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("PresaleBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Bundlings")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Requests")
.HasForeignKey("PresaleId");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Navigation("CarBundling");
b.Navigation("PresaleBundling");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Navigation("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Navigation("Cars");
b.Navigation("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Navigation("Bundlings");
b.Navigation("OrderPresales");
b.Navigation("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,78 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarCenterDatabaseImplement.Migrations
{
public partial class Test : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Requests_Presales_PresaleId",
table: "Requests");
migrationBuilder.AlterColumn<int>(
name: "PresaleId",
table: "Requests",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AddColumn<int>(
name: "WorkerId",
table: "Requests",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "WorkerId",
table: "Presales",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_Requests_Presales_PresaleId",
table: "Requests",
column: "PresaleId",
principalTable: "Presales",
principalColumn: "Id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Requests_Presales_PresaleId",
table: "Requests");
migrationBuilder.DropColumn(
name: "WorkerId",
table: "Requests");
migrationBuilder.DropColumn(
name: "WorkerId",
table: "Presales");
migrationBuilder.AlterColumn<int>(
name: "PresaleId",
table: "Requests",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Requests_Presales_PresaleId",
table: "Requests",
column: "PresaleId",
principalTable: "Presales",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -230,6 +230,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Presales");
@ -270,12 +273,15 @@ namespace CarCenterDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int>("PresaleId")
b.Property<int?>("PresaleId")
.HasColumnType("integer");
b.Property<int>("RequestType")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PresaleId");
@ -448,9 +454,7 @@ namespace CarCenterDatabaseImplement.Migrations
{
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Requests")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("PresaleId");
b.Navigation("Presale");
});

View File

@ -49,7 +49,7 @@ namespace CarCenterDatabaseImplement.Models
{
return null;
}
return new Presale()
var presale = new Presale()
{
Id = model.Id,
PresaleStatus = model.PresaleStatus,
@ -62,6 +62,17 @@ namespace CarCenterDatabaseImplement.Models
Bundling = context.Bundlings.First(y => y.Id == x.Key)
}).ToList()
};
foreach (var requestId in model.RequestIds)
{
var request = context.Requests.FirstOrDefault(x => x.Id == requestId);
if (request != null)
{
presale.Requests.Add(request);
}
}
return presale;
}
public void UpdateBundlings(CarCenterDatabase context, PresaleBindingModel model)
@ -78,8 +89,16 @@ namespace CarCenterDatabaseImplement.Models
}
_presaleBundlings = null;
}
public void Update(PresaleBindingModel? model)
public void AddRequests(CarCenterDatabase context, List<int> requestIds)
{
var presale = context.Presales.First(x => x.Id == Id);
foreach (var requestId in requestIds)
{
var request = context.Requests.First(x => x.Id == requestId);
presale.Requests.Add(request);
}
}
public void Update(PresaleBindingModel? model)
{
if (model == null)
{

View File

@ -15,12 +15,12 @@ namespace CarCenterDatabaseImplement.Models
{
public int Id { get; set; }
public int WorkerId { get; set; }
public int PresaleId { get; set; }
public int? PresaleId { get; set; }
[Required]
public string Description { get; set; } = string.Empty;
[Required]
public RequestTypes RequestType { get; set; } = RequestTypes.Неизвестно;
public virtual Presale Presale { get; set; }
public virtual Presale? Presale { get; set; }
public static Request? Create(RequestBindingModel? model)
{

View File

@ -1,6 +1,7 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.ViewModels;
using CarCenterDatabaseImplement.Models;
using CarCenterDataModels.Enums;
using CarCenterWorkerApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
@ -109,15 +110,8 @@ namespace CarCenterWorkerApp.Controllers
return View(new RequestViewModel());
}
[HttpPost]
public IActionResult CreateRequest(RequestBindingModel model, int[] presalesIds)
public IActionResult CreateRequest(RequestBindingModel model)
{
var presales = _data.GetPresales(UserWorker.user!.Id);
for (int i = 0; i < presalesIds.Length; i++)
{
var presale = presales!.FirstOrDefault(x => x.Id == presalesIds[i])!;
model.RequestPresales[presalesIds[i]] = presale;
sum += presale.Price;
}
if (model.Id == 0)
{
model.WorkerId = UserWorker.user!.Id;
@ -133,5 +127,69 @@ namespace CarCenterWorkerApp.Controllers
return View();
}
}
[HttpGet]
public IActionResult IndexPresale()
{
if (UserWorker.user != null)
{
var productions = _data.GetPresales(UserWorker.user.Id);
return View(productions);
}
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public IActionResult IndexPresale(int id)
{
_data.DeletePresale(id);
return RedirectToAction("IndexPresale");
}
[HttpGet]
public IActionResult CreatePresale(int id)
{
var bundlings = _data.GetBundlings();
var requests = _data.GetRequests(UserWorker.user!.Id);
ViewBag.AllBundlings = bundlings;
ViewBag.Requests = requests;
if (id != 0)
{
var value = _data.GetPresale(id);
if (value != null)
return View(value);
}
return View(new PresaleViewModel());
}
[HttpPost]
public IActionResult CreatePresale(PresaleBindingModel model,int[] bundlingIds)
{
var bundlings = _data.GetBundlings();
for (int i = 0; i < bundlingIds.Length; i++)
{
var bundling = bundlings!.FirstOrDefault(x => x.Id == bundlingIds[i])!;
model.PresaleBundlings.Add(i, bundling);
}
var requests = _data.GetRequests(UserWorker.user!.Id);
model.RequestIds = model.RequestIds.Where(id => requests.Any(r => r.Id == id)).ToList();
bool changed = false;
if (model.PresaleBundlings.Count > 0)
{
if (model.Id != 0)
{
changed = _data.UpdatePresale(model);
}
else
{
changed = _data.CreatePresale(model);
}
}
if (changed)
return RedirectToAction("IndexPresale");
else
{
ViewBag.AllBundlings = bundlings;
return View(model);
}
}
}
}

View File

@ -1,23 +1,21 @@
@{
ViewData["Title"] = "Enter";
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин(почта):</div>
<div class="col-8"><input type="email" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Войти"
class="btn btn-primary" />
</div>
</div>
</form>
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -3,5 +3,14 @@
}
<div class="text-center">
<img src="./Images/cat.png" alt="logo">
<h1 class="display-4">Главное меню</h1>
<div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexRequest">Пожелания</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexPresale">Предпродажные</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexOrder">Покупки</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
@* <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportsMenu">Меню отчетов</a> *@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
</div>
</div>

View File

@ -3,6 +3,7 @@ using CarCenterContracts.ViewModels;
using CarCenterContracts.BindingModels;
using CarCenterContracts.StoragesContracts;
using CarCenterContracts.SearchModels;
using CarCenterBusinessLogic.BusinessLogics;
namespace WorkerApp
{
@ -13,17 +14,19 @@ namespace WorkerApp
private readonly IPresaleLogic _presaleLogic;
private readonly IRequestLogic _requestLogic;
private readonly IOrderLogic _orderLogic;
private readonly IBundlingLogic _bundlingLogic;
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IPresaleLogic presaleLogic, IRequestLogic requestLogic, IOrderLogic orderLogic)
{
_logger = logger;
_storekeeperLogic = storekeeperLogic;
_presaleLogic = presaleLogic;
_requestLogic = requestLogic;
_orderLogic = orderLogic;
}
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IPresaleLogic presaleLogic, IRequestLogic requestLogic, IOrderLogic orderLogic, IBundlingLogic bundlingLogic)
{
_logger = logger;
_storekeeperLogic = storekeeperLogic;
_presaleLogic = presaleLogic;
_requestLogic = requestLogic;
_orderLogic = orderLogic;
_bundlingLogic = bundlingLogic;
}
public WorkerViewModel? Login(string email, string password)
public WorkerViewModel? Login(string email, string password)
{
return _storekeeperLogic.ReadElement(new()
{
@ -100,6 +103,9 @@ namespace WorkerApp
{
return _orderLogic.Delete(new() { Id = orderId });
}
}
public List<BundlingViewModel>? GetBundlings()
{
return _bundlingLogic.ReadList(null);
}
}
}