Compare commits

..

No commits in common. "f308e1762b3f7e6cc54f5144f06c7f560b9b6c4d" and "6acd4ab8a1103376326acdb6a98df748b761f12a" have entirely different histories.

49 changed files with 768 additions and 1309 deletions

View File

@ -100,15 +100,7 @@ namespace CarCenterBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Нет телефона", nameof(model.PhoneNumber));
}
var elem = _storekeeperStorage.GetElement(new StorekeeperSearchModel
{
Email = model.Email
});
if (elem != null && model.Id != elem.Id)
{
throw new InvalidOperationException("Такая почта уже используется в системе");
}
_logger.LogInformation("Storekeeper. Storekeeper:Id:{ Id}.PhoneNumber:{ PhoneNumber}", model.Id, model.PhoneNumber);
_logger.LogInformation("Storekeeper. Storekeeper:Id:{ Id}.PhoneNumber:{ PhoneNumber}", model.Id, model.PhoneNumber);
}
}
}

View File

@ -15,6 +15,5 @@ namespace CarCenterContracts.BindingModels
public TirePackage TirePackage { get; set; } = TirePackage.Неизвестно;
public ToolKit ToolKit { get; set; } = ToolKit.Неизвестно;
public double Price { get; set; }
public int StorekeeperId { get; set; }
}
}

View File

@ -12,6 +12,7 @@ namespace CarCenterContracts.BindingModels
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
public int OrderId { get; set; }
public CarBrand CarBrand { get; set; } = CarBrand.Неизвестно;
public string Model { get; set; } = string.Empty;
public CarClass CarClass { get; set; } = CarClass.Неизвестно;

View File

@ -11,8 +11,7 @@ namespace CarCenterContracts.BindingModels
public class FeatureBindingModel : IFeatureModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
public HelpDevices HelpDevice { get; set; } = HelpDevices.Неизвестно;
public HelpDevices HelpDevice { get; set; } = HelpDevices.Неизвестно;
public string CabinColor { get; set; } = string.Empty;
public DriveTypes DriveType { get; set; } = DriveTypes.Неизвестно;
public double Price { get; set; }

View File

@ -9,6 +9,5 @@ namespace CarCenterContracts.SearchModels
public class BundlingSearchModel
{
public int? Id { get; set; }
public int? StorekeeperId { get; set; }
}
}

View File

@ -9,6 +9,5 @@ namespace CarCenterContracts.SearchModels
public class FeatureSearchModel
{
public int? Id { get; set; }
public int? StorekeeperId { get; set; }
}
}
}

View File

@ -9,8 +9,6 @@ namespace CarCenterContracts.SearchModels
public class StorekeeperSearchModel
{
public int? Id { get; set; }
public string? Email { get; set; }
public string? Password { get; set; }
}
}

View File

@ -12,8 +12,7 @@ namespace CarCenterContracts.ViewModels
public class BundlingViewModel : IBundlingModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
[DisplayName("Пакет оборудования")]
[DisplayName("Пакет оборудования")]
public EquipmentPackage EquipmentPackage { get; set; }
[DisplayName("Пакет шин")]
public TirePackage TirePackage { get; set; }

View File

@ -15,7 +15,11 @@ namespace CarCenterContracts.ViewModels
public int? OrderId { get; set; }
[DisplayName("ФИО покупателя")]
public string BuyerFCS { get; set; } = string.Empty;
[DisplayName("Цена особенности")]
public double FeaturePrice { get; set; }
public int StorekeeperId { get; set; }
[DisplayName("Имя кладовщика")]
public string StorekeeperName { get; set; } = string.Empty;
[DisplayName("Марка")]
public CarBrand CarBrand { get; set; }
[DisplayName("Модель")]

View File

@ -12,8 +12,7 @@ namespace CarCenterContracts.ViewModels
public class FeatureViewModel : IFeatureModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
[DisplayName("Вспомогательные устройства")]
[DisplayName("Вспомогательные устройства")]
public HelpDevices HelpDevice { get; set; }
[DisplayName("Цвет салона")]
public string CabinColor { get; set; } = string.Empty;

View File

@ -23,11 +23,11 @@ namespace CarCenterDatabaseImplement.Implements
public List<BundlingViewModel> GetFilteredList(BundlingSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.StorekeeperId.HasValue)
if (model.Id.HasValue)
{
return context.Bundlings
.Where(x => x.StorekeeperId == model.StorekeeperId)
.Select(x => x.GetViewModel)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
return new();

View File

@ -43,7 +43,7 @@ namespace CarCenterDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.StorekeeperId.HasValue)
else if (model.Id.HasValue)
{
return context.Cars
.Where(x => x.StorekeeperId == model.StorekeeperId)
@ -52,6 +52,7 @@ namespace CarCenterDatabaseImplement.Implements
.Include(x => x.Feature)
.Include(x => x.Order)
.Include(x => x.Storekeeper)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -24,10 +24,10 @@ namespace CarCenterDatabaseImplement.Implements
public List<FeatureViewModel> GetFilteredList(FeatureSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.StorekeeperId.HasValue)
if (model.Id.HasValue)
{
return context.Features
.Where(x => x.StorekeeperId == model.StorekeeperId)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -42,9 +42,12 @@ namespace CarCenterDatabaseImplement.Implements
public StorekeeperViewModel? GetElement(StorekeeperSearchModel model)
{
using var context = new CarCenterDatabase();
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Email)) { return null; }
return context.Storekeepers.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;
if (!model.Id.HasValue) { return null; }
if (model.Id.HasValue)
return context.Storekeepers
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
return null;
}

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240528175849_Initia8")]
partial class Initia8
[Migration("20240428140324_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -38,9 +38,6 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<int>("TirePackage")
.HasColumnType("integer");
@ -76,7 +73,7 @@ namespace CarCenterDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int?>("OrderId")
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<double>("Price")
@ -146,9 +143,6 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Features");
@ -363,7 +357,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Cars")
.HasForeignKey("OrderId");
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
.WithMany("Cars")

View File

@ -6,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
public partial class Initia8 : Migration
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -16,7 +16,6 @@ namespace CarCenterDatabaseImplement.Migrations
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
EquipmentPackage = table.Column<int>(type: "integer", nullable: false),
TirePackage = table.Column<int>(type: "integer", nullable: false),
ToolKit = table.Column<int>(type: "integer", nullable: false),
@ -33,7 +32,6 @@ namespace CarCenterDatabaseImplement.Migrations
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
HelpDevice = table.Column<int>(type: "integer", nullable: false),
CabinColor = table.Column<string>(type: "text", nullable: false),
DriveType = table.Column<int>(type: "integer", nullable: false),
@ -174,6 +172,7 @@ namespace CarCenterDatabaseImplement.Migrations
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
OrderId = table.Column<int>(type: "integer", nullable: false),
FeatureId = table.Column<int>(type: "integer", nullable: true),
CarBrand = table.Column<int>(type: "integer", nullable: false),
Model = table.Column<string>(type: "text", nullable: false),
@ -181,8 +180,7 @@ namespace CarCenterDatabaseImplement.Migrations
Year = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
VINnumber = table.Column<long>(type: "bigint", nullable: false),
FeatureID = table.Column<int>(type: "integer", nullable: false),
OrderId = table.Column<int>(type: "integer", nullable: true)
FeatureID = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
@ -196,7 +194,8 @@ namespace CarCenterDatabaseImplement.Migrations
name: "FK_Cars_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Cars_Storekeepers_StorekeeperId",
column: x => x.StorekeeperId,

View File

@ -36,9 +36,6 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<int>("TirePackage")
.HasColumnType("integer");
@ -74,7 +71,7 @@ namespace CarCenterDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int?>("OrderId")
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<double>("Price")
@ -144,9 +141,6 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Features");
@ -361,7 +355,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Cars")
.HasForeignKey("OrderId");
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
.WithMany("Cars")

View File

@ -16,8 +16,7 @@ namespace CarCenterDatabaseImplement.Models
public class Bundling : IBundlingModel
{
public int Id { get; private set; }
public int StorekeeperId { get; set; }
[Required]
[Required]
public EquipmentPackage EquipmentPackage { get; set; } = EquipmentPackage.Неизвестно;
[Required]
public TirePackage TirePackage { get; set; } = TirePackage.Неизвестно;
@ -38,7 +37,6 @@ namespace CarCenterDatabaseImplement.Models
return new Bundling()
{
Id = model.Id,
StorekeeperId = model.StorekeeperId,
EquipmentPackage = model.EquipmentPackage,
TirePackage = model.TirePackage,
ToolKit = model.ToolKit,
@ -50,7 +48,6 @@ namespace CarCenterDatabaseImplement.Models
return new Bundling
{
Id = model.Id,
StorekeeperId=model.StorekeeperId,
EquipmentPackage = model.EquipmentPackage,
TirePackage = model.TirePackage,
ToolKit = model.ToolKit,
@ -63,7 +60,6 @@ namespace CarCenterDatabaseImplement.Models
{
return;
}
StorekeeperId = model.StorekeeperId;
EquipmentPackage = model.EquipmentPackage;
TirePackage = model.TirePackage;
ToolKit = model.ToolKit;
@ -72,7 +68,6 @@ namespace CarCenterDatabaseImplement.Models
public BundlingViewModel GetViewModel => new()
{
Id = Id,
StorekeeperId = StorekeeperId,
EquipmentPackage = EquipmentPackage,
TirePackage = TirePackage,
ToolKit = ToolKit,

View File

@ -17,6 +17,7 @@ namespace CarCenterDatabaseImplement.Models
{
public int Id { get; private set; }
public int StorekeeperId { get; set; }
public int OrderId { get; set; }
public int? FeatureId { get; set; }
[Required]
public CarBrand CarBrand { get; set; } = CarBrand.Неизвестно;
@ -34,7 +35,7 @@ namespace CarCenterDatabaseImplement.Models
public int FeatureID { get; set; }
public virtual Storekeeper Storekeeper { get; set; }
public virtual Feature Feature { get; set; }
public virtual Order? Order { get; set; }
public virtual Order Order { get; set; }
private Dictionary<int, IBundlingModel>? _carBundlings = null;
[ForeignKey("CarId")]
@ -62,6 +63,7 @@ namespace CarCenterDatabaseImplement.Models
Id = model.Id,
StorekeeperId = model.StorekeeperId,
FeatureId = model.FeatureID,
OrderId = model.OrderId,
CarBrand = model.CarBrand,
Model = model.Model,
CarClass = model.CarClass,
@ -99,6 +101,7 @@ namespace CarCenterDatabaseImplement.Models
}
StorekeeperId = model.StorekeeperId;
FeatureId = model.FeatureID;
OrderId = model.OrderId;
CarBrand = model.CarBrand;
Model = model.Model;
CarClass = model.CarClass;
@ -111,6 +114,9 @@ namespace CarCenterDatabaseImplement.Models
{
Id = Id,
StorekeeperId = StorekeeperId,
StorekeeperName = Storekeeper?.Name ?? string.Empty,// не понял че было
FeaturePrice = Feature?.Price ?? 0,
OrderId = OrderId,
BuyerFCS = Order?.BuyerFCS ?? string.Empty,
CarBrand = CarBrand,
Model = Model,

View File

@ -16,8 +16,7 @@ namespace CarCenterDatabaseImplement.Models
public class Feature : IFeatureModel
{
public int Id { get; private set; }
public int StorekeeperId { get; set; }
[Required]
[Required]
public HelpDevices HelpDevice { get; set; } = HelpDevices.Неизвестно;
[Required]
public string CabinColor { get; set; } = string.Empty;
@ -41,7 +40,6 @@ namespace CarCenterDatabaseImplement.Models
CabinColor = model.CabinColor,
DriveType = model.DriveType,
Price = model.Price,
StorekeeperId = model.StorekeeperId,
};
}
public static Feature Create(FeatureViewModel model)
@ -49,7 +47,6 @@ namespace CarCenterDatabaseImplement.Models
return new Feature
{
Id = model.Id,
StorekeeperId = model.StorekeeperId,
HelpDevice = model.HelpDevice,
CabinColor = model.CabinColor,
DriveType = model.DriveType,
@ -62,7 +59,6 @@ namespace CarCenterDatabaseImplement.Models
{
return;
}
StorekeeperId = model.StorekeeperId;
HelpDevice = model.HelpDevice;
CabinColor = model.CabinColor;
DriveType = model.DriveType;
@ -71,7 +67,6 @@ namespace CarCenterDatabaseImplement.Models
public FeatureViewModel GetViewModel => new()
{
Id = Id,
StorekeeperId = StorekeeperId,
HelpDevice = HelpDevice,
CabinColor = CabinColor,
DriveType = DriveType,

View File

@ -53,9 +53,6 @@ namespace CarCenterDatabaseImplement.Models
return;
}
Password = model.Password;
Name = model.Name;
Surname = model.Surname;
Patronymic = model.Patronymic;
Email = model.Email;
PhoneNumber = model.PhoneNumber;
}

View File

@ -1,281 +1,94 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.ViewModels;
using CarCenterStorekeeperApp.Models;
using StorekeeperApp;
using CarCenterStorekeeperApp.Models;
using Microsoft.AspNetCore.Mvc;
using StorekeeperApp;
using System.Diagnostics;
using System.IO;
using System.Numerics;
using ImplementerApp;
using CarCenterDataModels.Enums;
namespace CarCenterStorekeeperApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly StorekeeperData _data;
public HomeController(ILogger<HomeController> logger, StorekeeperData data)
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
_data = data;
}
private bool IsLoggedIn { get { return UserStorekeeper.user != null; } }
private int UserId { get { return UserStorekeeper.user!.Id; } }
public IActionResult IndexNonReg()
{
if (!IsLoggedIn)
return View();
return RedirectToAction("Index");
}
[HttpGet]
public IActionResult Index()
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
return View();
}
[HttpGet]
public IActionResult Enter()
{
if (!IsLoggedIn)
return View();
return RedirectToAction("Index");
}
[HttpPost]
public void Enter(string login, string password)
{
var user = _data.Login(login, password);
if (user != null)
{
UserStorekeeper.user = user;
Response.Redirect("Index");
}
return View();
}
[HttpGet]
public IActionResult Register()
{
return View();
}
public IActionResult Logout()
{
UserStorekeeper.user = null;
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public void Register(string name, string surname, string patronymic, string email, long phone, string password1, string password2)
{
if (password1 == password2 && _data.Register(new() { Email = email, Name = name, Password = password1, Surname = surname,
Patronymic = patronymic, PhoneNumber = phone}))
{
Response.Redirect("Index");
}
}
[HttpGet]
public IActionResult IndexBundling()
public IActionResult Bundlings()
{
if (UserStorekeeper.user != null)
{
var list = _data.GetBundlings(UserStorekeeper.user.Id);
if (list != null)
return View(list);
return View(new List<BundlingViewModel>());
}
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public void IndexBundling(int id)
{
if (UserStorekeeper.user != null)
{
_data.DeleteBundling(id);
}
Response.Redirect("IndexBundling");
}
[HttpGet]
public IActionResult CreateBundling(int id)
{
if (id != 0)
{
var value = _data.GetBundling(id);
if (value != null)
return View(value);
}
return View(new BundlingViewModel());
}
[HttpPost]
public IActionResult CreateBundling(BundlingBindingModel model)
{
if (model.Id == 0)
{
model.StorekeeperId = UserStorekeeper.user!.Id;
if (_data.CreateBundling(model))
return RedirectToAction("IndexBundling");
}
else
{
model.StorekeeperId = UserStorekeeper.user!.Id;
if (_data.UpdateBundling(model))
return RedirectToAction("IndexBundling");
}
return View();
}
[HttpGet]
public IActionResult IndexFeature()
public IActionResult BundlingCreate()
{
if (UserStorekeeper.user != null)
{
var list = _data.GetFeatures(UserStorekeeper.user.Id);
if (list != null)
return View(list);
return View(new List<FeatureViewModel>());
}
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public void IndexFeature(int id)
{
if (UserStorekeeper.user != null)
{
_data.DeleteFeature(id);
}
Response.Redirect("IndexFeature");
return View();
}
[HttpGet]
public IActionResult BundlingDelete()
{
return View();
}
[HttpGet]
public IActionResult CreateFeature(int id)
public IActionResult BundlingUpdate()
{
if (id != 0)
{
var value = _data.GetFeature(id);
if (value != null)
return View(value);
}
return View(new FeatureViewModel());
}
[HttpPost]
public IActionResult CreateFeature(FeatureBindingModel model)
{
if (model.Id == 0)
{
model.StorekeeperId = UserStorekeeper.user!.Id;
if (_data.CreateFeature(model))
return RedirectToAction("IndexFeature");
}
else
{
model.StorekeeperId = UserStorekeeper.user!.Id;
if (_data.UpdateFeature(model))
return RedirectToAction("IndexFeature");
}
return View();
}
[HttpGet]
public IActionResult IndexCar()
public IActionResult Features()
{
if (UserStorekeeper.user != null)
{
var productions = _data.GetCars(UserStorekeeper.user.Id);
return View(productions);
}
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public IActionResult IndexCar(int id)
{
_data.DeleteCar(id);
return RedirectToAction("IndexCar");
return View();
}
[HttpGet]
public IActionResult CreateCar(int id)
public IActionResult FeatureCreate()
{
var bundlings = _data.GetBundlings(UserStorekeeper.user!.Id);
var features = _data.GetFeatures(UserStorekeeper.user!.Id);
ViewBag.AllBundlings = bundlings;
ViewBag.Features = features;
if (id != 0)
{
var value = _data.GetCar(id);
if (value != null)
return View(value);
}
return View(new CarViewModel());
return View();
}
[HttpPost]
public IActionResult CreateCar(int id, int year, long VINnumber, CarBrand CarBrand, CarClass CarClass, int FeatureId, string Model, int[] bundlingIds)
{
CarBindingModel model = new CarBindingModel();
model.Id = id;
model.Year = year;
model.VINnumber = VINnumber;
model.CarBrand = CarBrand;
model.CarClass = CarClass;
model.FeatureID = FeatureId;
model.Model = Model;
model.StorekeeperId = UserStorekeeper.user!.Id;
var bundlings = _data.GetBundlings(UserStorekeeper.user!.Id);
double sum = 0;
for (int i = 0; i < bundlingIds.Length; i++)
{
var bundling = bundlings!.FirstOrDefault(x => x.Id == bundlingIds[i])!;
model.CarBundlings[bundlingIds[i]] = bundling;
sum += bundling.Price;
}
model.Price = sum;
bool changed = false;
if (model.CarBundlings.Count > 0)
{
if (id != 0)
{
changed = _data.UpdateCar(model);
}
else
{
changed = _data.CreateCar(model);
}
}
if (changed)
return RedirectToAction("IndexCar");
else
{
ViewBag.AllBundlings = bundlings;
return View(model);
}
}
[HttpGet]
public IActionResult Privacy()
{
if (IsLoggedIn)
return View(UserStorekeeper.user);
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public IActionResult Privacy(int id, string surname, string patronymic, string email, long phone, string password, string name)
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
StorekeeperBindingModel user = new() { Id = id,
Email = email,
Name = name,
Surname = surname,
Patronymic = patronymic,
PhoneNumber = phone
};
if (_data.UpdateUser(user))
{
UserStorekeeper.user = new StorekeeperViewModel { Id = id,
Email = email,
Name = name,
Surname = surname,
Patronymic = patronymic,
PhoneNumber = phone
};
}
return View(user);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult FeatureDelete()
{
return View();
}
[HttpGet]
public IActionResult FeatureUpdate()
{
return View();
}
[HttpGet]
public IActionResult Cars()
{
return View();
}
[HttpGet]
public IActionResult CarCreate()
{
return View();
}
[HttpGet]
public IActionResult CarDelete()
{
return View();
}
[HttpGet]
public IActionResult CarUpdate()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });

View File

@ -2,7 +2,6 @@ using CarCenterBusinessLogic.BusinessLogics;
using CarCenterContracts.BusinessLogicsContracts;
using CarCenterContracts.StoragesContracts;
using CarCenterDatabaseImplement.Implements;
using StorekeeperApp;
var builder = WebApplication.CreateBuilder(args);
@ -28,7 +27,6 @@ builder.Services.AddTransient<IPresaleLogic, PresaleLogic>();
builder.Services.AddTransient<IRequestLogic, RequestLogic>();
builder.Services.AddTransient<IStorekeeperLogic, StorekeeperLogic>();
builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
builder.Services.AddTransient<StorekeeperData>();
var app = builder.Build();

View File

@ -1,105 +0,0 @@
using CarCenterContracts.BusinessLogicsContracts;
using CarCenterContracts.ViewModels;
using CarCenterContracts.BindingModels;
using CarCenterContracts.StoragesContracts;
using CarCenterContracts.SearchModels;
namespace StorekeeperApp
{
public class StorekeeperData
{
private readonly ILogger _logger;
private readonly IStorekeeperLogic _storekeeperLogic;
private readonly IBundlingLogic _bundlingLogic;
private readonly IFeatureLogic _featureLogic;
private readonly ICarLogic _carLogic;
public StorekeeperData(ILogger<StorekeeperData> logger, IStorekeeperLogic storekeeperLogic, IBundlingLogic bundlingLogic, IFeatureLogic featureLogic, ICarLogic carLogic)
{
_logger = logger;
_storekeeperLogic = storekeeperLogic;
_bundlingLogic = bundlingLogic;
_featureLogic = featureLogic;
_carLogic = carLogic;
}
public StorekeeperViewModel? Login(string email, string password)
{
return _storekeeperLogic.ReadElement(new()
{
Email = email,
Password = password
});
}
public bool Register(StorekeeperBindingModel model)
{
return _storekeeperLogic.Create(model);
}
public bool UpdateUser(StorekeeperBindingModel model)
{
return _storekeeperLogic.Update(model);
}
public List<BundlingViewModel>? GetBundlings(int userId)
{
return _bundlingLogic.ReadList(new BundlingSearchModel() { StorekeeperId = userId });
}
public bool DeleteBundling(int bundlingId)
{
return _bundlingLogic.Delete(new() { Id = bundlingId });
}
public bool CreateBundling(BundlingBindingModel model)
{
return _bundlingLogic.Create(model);
}
public bool UpdateBundling(BundlingBindingModel model)
{
return _bundlingLogic.Update(model);
}
public BundlingViewModel? GetBundling(int id)
{
return _bundlingLogic.ReadElement(new() { Id = id });
}
public List<FeatureViewModel>? GetFeatures(int userId)
{
return _featureLogic.ReadList(new FeatureSearchModel() { StorekeeperId = userId });
}
public bool DeleteFeature(int bundlingId)
{
return _featureLogic.Delete(new() { Id = bundlingId });
}
public bool CreateFeature(FeatureBindingModel model)
{
return _featureLogic.Create(model);
}
public bool UpdateFeature(FeatureBindingModel model)
{
return _featureLogic.Update(model);
}
public FeatureViewModel? GetFeature(int id)
{
return _featureLogic.ReadElement(new() { Id = id });
}
public List<CarViewModel>? GetCars(int userId)
{
return _carLogic.ReadList(new() { StorekeeperId = userId });
}
public CarViewModel? GetCar(int id)
{
return _carLogic.ReadElement(new() { Id = id });
}
public bool CreateCar(CarBindingModel model)
{
return _carLogic.Create(model);
}
public bool UpdateCar(CarBindingModel model)
{
return _carLogic.Update(model);
}
public bool DeleteCar(int carId)
{
return _carLogic.Delete(new() { Id = carId });
}
}
}

View File

@ -1,9 +0,0 @@
using CarCenterContracts.ViewModels;
namespace ImplementerApp
{
public static class UserStorekeeper
{
public static StorekeeperViewModel? user { get; set; }
}
}

View File

@ -0,0 +1,53 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "BundlingCreate";
}
<div class="text-center">
<h2 class="display-4">Создание комплектации</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Пакет оборудования:</div>
<div class="col-8">
<select name="equipmentPackage" id="equipmentPackage">
@foreach (var value in Enum.GetValues(typeof(EquipmentPackage)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Пакет шин:</div>
<div class="col-8">
<select name="tirePackage" id="tirePackage">
@foreach (var value in Enum.GetValues(typeof(TirePackage)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Пакет инструментов:</div>
<div class="col-8">
<select name="toolKit" id="toolKit">
@foreach (var value in Enum.GetValues(typeof(ToolKit)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></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

@ -0,0 +1,16 @@
@{
ViewData["Title"] = "BundlingDelete";
}
<div class="text-center">
<h2 class="display-4">Удалить комплектацию</h2>
</div>
<form method="post">
<div class="row">
<div class="col-8">
<select id="bundling" name="bundling" class="form-control" asp-items="@(new SelectList(@ViewBag.Bundlings,"Id"))"></select>
</div>
</div>
<div class="col-4">
<input type="submit" value="Удалить" class="btn btn-danger" />
</div>
</form>

View File

@ -0,0 +1,57 @@
<!-- Страница обновления комплектации. Самой логики нет, она будет в 3 этапе курсовой работы, поэтому пока так. -->
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "BundlingUpdate";
}
<div class="text-center">
<h2 class="display-4 mb-5">Обновить комплектацию</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">Комплектация:</div>
<div class="col-8">
<select id="bundling" name="bundling" class="form-control" asp-items="@(new SelectList(@ViewBag.Bundlings,"Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Пакет оборудования:</div>
<div class="col-8">
<select name="equipmentPackage" id="equipmentPackage">
@foreach (var value in Enum.GetValues(typeof(EquipmentPackage)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Пакет шин:</div>
<div class="col-8">
<select name="tirePackage" id="tirePackage">
@foreach (var value in Enum.GetValues(typeof(TirePackage)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Пакет инструментов:</div>
<div class="col-8">
<select name="toolKit" id="toolKit">
@foreach (var value in Enum.GetValues(typeof(ToolKit)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></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

@ -0,0 +1,60 @@
@using CarCenterContracts.ViewModels;
@model List<BundlingViewModel>
@{
ViewData["Title"] = "Bundlings";
}
<div class="text-center">
<h1 class="display-4">Комплектации</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h2 class="display-4">Надо войти в аккаунт.</h2>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать комлпектацию</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить комплектацию</a>
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить комплектацию</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Пакет оборудования
</th>
<th>
Пакет шин
</th>
<th>
Пакет инструментов
</th>
<th>
Цена
</th>
</tr>
</thead>
<tbody>
@foreach (var bundling in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => bundling.EquipmentPackage)
</td>
<td>
@Html.DisplayFor(modelItem => bundling.TirePackage)
</td>
<td>
@Html.DisplayFor(modelItem => bundling.ToolKit)
</td>
<td>
@Html.DisplayFor(modelItem => bundling.Price)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,61 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "CarCreate";
}
<div class="text-center">
<h2 class="display-4">Создание машины</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Марка:</div>
<div class="col-8">
<select name="brandType" id="brandType">
@foreach (var value in Enum.GetValues(typeof(CarBrand)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Модель:</div>
<div class="col-8"><input type="text" name="model" id="model" /></div>
</div>
<div class="row">
<div class="col-4">Марка:</div>
<div class="col-8">
<select name="carClass" id="carClass">
@foreach (var value in Enum.GetValues(typeof(CarClass)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8">Особенность:</div>
<!--Без реализации логики четко не ясно что тут писать-->
<select id="feature" name="feature" class="form-control" asp-items="@(new SelectList(@ViewBag.Features,"Id"))"></select>
</div>
<div class="row">
<div class="col-4">Год:</div>
<div class="col-8"><input type="text" name="year" id="year" /></div>
</div>
<div class="row">
<div class="col-4">Вин-номер:</div>
<div class="col-8"><input type="text" name="vin" id="vin" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-2"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
<div class="col-4"></div>
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
</div>
</form>

View File

@ -0,0 +1,19 @@
@{
ViewData["Title"] = "CarDelete";
}
<div class="text-center">
<h2 class="display-4">Удалить машину</h2>
</div>
<form method="post">
<div class="row">
<div class="col-8">
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-2"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
<div class="col-4"></div>
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
</div>
</form>

View File

@ -0,0 +1,67 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "CarUpdate";
}
<div class="text-center">
<h2 class="display-4">Обновление машины</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">Машина</div>
<div class="col-8">
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Марка:</div>
<div class="col-8">
<select name="brandType" id="brandType">
@foreach (var value in Enum.GetValues(typeof(CarBrand)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Модель:</div>
<div class="col-8"><input type="text" name="model" id="model" /></div>
</div>
<div class="row">
<div class="col-4">Марка:</div>
<div class="col-8">
<select name="carClass" id="carClass">
@foreach (var value in Enum.GetValues(typeof(CarClass)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8">Особенность:</div>
<!--Без реализации логики четко не ясно что тут писать-->
<select id="feature" name="feature" class="form-control" asp-items="@(new SelectList(@ViewBag.Features,"Id"))"></select>
</div>
<div class="row">
<div class="col-4">Год:</div>
<div class="col-8"><input type="text" name="year" id="year" /></div>
</div>
<div class="row">
<div class="col-4">Вин-номер:</div>
<div class="col-8"><input type="text" name="vin" id="vin" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-2"><input type="submit" value="Обновить" class="btn btn-primary" /></div>
<div class="col-4"></div>
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
</div>
</form>

View File

@ -0,0 +1,102 @@
@using CarCenterContracts.ViewModels
@model List<CarViewModel>
@{
ViewData["Title"] = "Cars";
}
<div class="text-center">
<h1 class="display-4">Машины</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h2 class="display-4">Надо войти в аккаунт.</h2>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать машину</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить машину</a>
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить машину</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер заказа
</th>
<th>
Покупатель
</th>
<th>
Цена особенности
</th>
<th>
Имя кладовщика
</th>
<th>
Марка
</th>
<th>
Модель
</th>
<th>
Класс
</th>
<th>
Год выпуска
</th>
<th>
Вин-номер
</th>
<th>
Цена
</th>
<th>
Комплектации
</th>
</tr>
</thead>
<tbody>
@foreach (var car in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => car.OrderId)
</td>
<td>
@Html.DisplayFor(modelItem => car.BuyerFCS)
</td>
<td>
@Html.DisplayFor(modelItem => car.FeaturePrice)
</td>
<td>
@Html.DisplayFor(modelItem => car.StorekeeperName)
</td>
<td>
@Html.DisplayFor(modelItem => car.CarBrand)
</td>
<td>
@Html.DisplayFor(modelItem => car.Model)
</td>
<td>
@Html.DisplayFor(modelItem => car.CarClass)
</td>
<td>
@Html.DisplayFor(modelItem => car.Year)
</td>
<td>
@Html.DisplayFor(modelItem => car.VINnumber)
</td>
<td>
@Html.DisplayFor(modelItem => car.Price)
</td>
<td>
@Html.DisplayFor(modelItem => car.CarBundlings)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,86 +0,0 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "CreateBundling";
}
@model BundlingViewModel;
<div class="text-center">
<h2 class="display-4">Комплектация</h2>
</div>
<form id="bundlingForm" method="post">
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden" />
<div class="row">
<div class="col-4">Пакет оборудования:</div>
<div class="col-8">
<select name="EquipmentPackage" id="EquipmentPackage" value="@Model.EquipmentPackage">
@foreach (var value in Enum.GetValues(typeof(EquipmentPackage)))
{
<option value="@value">@value</option>
}
</select>
<span id="EquipmentPackageError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Пакет шин:</div>
<div class="col-8">
<select name="TirePackage" id="TirePackage" value="@Model.TirePackage">
@foreach (var value in Enum.GetValues(typeof(TirePackage)))
{
<option value="@value">@value</option>
}
</select>
<span id="TirePackageError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Пакет инструментов:</div>
<div class="col-8">
<select name="ToolKit" id="ToolKit" value="@Model.ToolKit">
@foreach (var value in Enum.GetValues(typeof(ToolKit)))
{
<option value="@value">@value</option>
}
</select>
<span id="ToolKiteError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8">
<input type="text" name="Price" id="Price" value="@Model.Price" />
<span id="PriceError" class="text-danger"></span>
</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>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#bundlinglForm').submit(function (event) {
var EquipmentPackage = $('#EquipmentPackage').val();
var TirePackage = $('#TirePackage').val();
var ToolKit = $('#ToolKit').val();
var Price = $('#Price').val();
var isValid = true;
$('#PriceError').text('');
$('#EquipmentPackageError').text('');
$('#TirePackageError').text('');
$('#ToolKitError').text('');
if (isNaN(price) || cost <= 0) {
$('#PriceError').text('Цена должна быть положительным числом.');
isValid = false;
}
if (!isValid) {
event.preventDefault();
}
});
});
</script>

View File

@ -1,213 +0,0 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@model CarViewModel
@{
ViewData["Title"] = "CreateCar";
ViewBag.Bundlings = Model.CarBundlings;
}
<div class="text-center">
<h2 class="display-4">Создание автомобиля</h2>
</div>
<form id="carForm" method="post">
<div class="row">
<div class="col-4">Марка:</div>
<div class="col-8">
<select name="CarBrand" id="CarBrand" value="@Model.CarBrand">
@foreach (var value in Enum.GetValues(typeof(CarBrand)))
{
<option value="@value">@value</option>
}
</select>
<span id="CarBrandError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Модель:</div>
<div class="col-8">
<input type="text" name="Model" id="Model" value="@Model.Model" />
<span id="ModelError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Класс:</div>
<div class="col-8">
<select name="CarClass" id="CarClass" value="@Model.CarClass">
@foreach (var value in Enum.GetValues(typeof(CarClass)))
{
<option value="@value">@value</option>
}
</select>
<span id="CarClassError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Год выпуска:</div>
<div class="col-8">
<input type="text" name="Year" id="Year" value="@Model.Year" />
<span id="YearError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">ВИН-номер:</div>
<div class="col-8">
<input type="text" name="VINnumber" id="VINnumber" value="@Model.VINnumber" />
<span id="VINnumberError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Особенность:</div>
<div class="col-8">
<select name="FeatureId" id="FeatureId">
@foreach (var feature in ViewBag.Features)
{
<option value="@feature.Id">Особенность @feature.Id</option>
}
</select>
<span id="FeatureIdError" class="text-danger"></span>
</div>
</div>
<div class="container">
<div>Детали</div>
<div class="table-responsive-lg">
<table id="bundlingsTable" class="display">
<thead>
<tr>
<th>ID комплектации</th>
<th> </th>
<th>Стоимость</th>
<th> </th>
<th>Удалить</th>
</tr>
</thead>
<tbody>
@foreach (var bundling in ViewBag.Bundlings)
{
<tr data-bundling-id="@bundling.Value.Id">
<td>
<input type="hidden" name="bundlingIds" value="@bundling.Value.Id" />@bundling.Value.Id
</td>
<th> </th>
<td class="bundling-price" data-price="@bundling.Value.Price">@bundling.Value.Price</td>
<th> </th>
<td><button type="button" class="deleteBundling" data-bundling-id="@bundling.Value.Id">Удалить</button></td>
</tr>
}
</tbody>
</table>
</div>
<select id="bundlingSelect" class="form-control">
<option value="">Выберите комплектацию</option>
@foreach (var bundling in ViewBag.AllBundlings)
{
<option value="@bundling.Id" data-price="@bundling.Price">Комплектация @bundling.Id</option>
}
</select>
<button type="button" id="addBundling" class="btn btn-secondary">Добавить комплектацию</button>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></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>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
<script>
$(document).ready(function () {
function updateSum() {
var sum = 0;
$('#bundlingsTable tbody tr').each(function () {
var price = $(this).find('.bundling-price').data('price');
sum += parseFloat(price);
});
$('#sum').val(sum.toFixed(2));
}
$(document).on('click', '.deleteBundling', function () {
var row = $(this).closest('tr');
row.remove();
updateSum();
});
$('#addBundling').click(function () {
var selectedBundling = $('#bundlingSelect option:selected');
if (selectedBundling.val()) {
var bundlingId = selectedBundling.val();
var exists = false;
$('#bundlingsTable tbody tr').each(function () {
if ($(this).data('bundling-id') == bundlingId) {
exists = true;
return false;
}
});
if (exists) {
alert('Эта комплектация уже добавлена.');
return;
}
var bundlingName = selectedBundling.text();
var bundlingPrice = selectedBundling.data('price');
var newRow = `
<tr data-bundling-id="${bundlingId}">
<td>
<input type="hidden" name="bundlingIds" value="${bundlingId}" />
${bundlingId}
</td>
<th> </th>
<td class="bundling-price" data-price="${bundlingPrice}">${bundlingPrice}</td>
<th> </th>
<td><button type="button" class="deleteBundling" data-bundling-id="${bundlingId}">Удалить</button></td>
</tr>
`;
$('#bundlingsTable tbody').append(newRow);
$('.deleteBundling').off('click').on('click', function () {
var row = $(this).closest('tr');
row.remove();
updateSum();
});
$('#bundlingSelect').val('');
updateSum();
} else {
alert('Выберите комплектацию для добавления');
}
});
$('#carForm').submit(function (event) {
var CarBrand = $('#CarBrand').val();
var FeatureID = $('#FeatureID').val();
var CarClass = $('#CarClass').val();
var Model = $('#Model').val();
var VINnumber = $('#VINnumber').val();
var Year = $('#Year').val();
var isValid = true;
$('#CarBrandError').text('');
$('#CarClassError').text('');
$('#ModelError').text('');
$('#VINnumberError').text('');
$('#YearError').text('');
var totalBundlings = $('#bundlingsTable tbody tr').length;
if (totalBundlings == 0) {
alert('Пожалуйста, добавьте хотя бы одну комплектацию.');
isValid = false;
}
if (!isValid) {
event.preventDefault();
}
});
updateSum();
});
</script>

View File

@ -1,83 +0,0 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@model FeatureViewModel;
@{
ViewData["Title"] = "CreateFeature";
}
<div class="text-center">
<h2 class="display-4">Особенность</h2>
</div>
<form id="featureForm" method="post">
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden" />
<div class="row">
<div class="col-4">Вспомогательные устройства:</div>
<div class="col-8">
<select name="HelpDevice" id="HelpDevice" value="@Model.HelpDevice">
@foreach (var value in Enum.GetValues(typeof(HelpDevices)))
{
<option value="@value">@value</option>
}
</select>
<span id="HelpDeviceError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Тип привода:</div>
<div class="col-8">
<select name="DriveType" id="DriveType" value="@Model.DriveType">
@foreach (var value in Enum.GetValues(typeof(DriveTypes)))
{
<option value="@value">@value</option>
}
</select>
<span id="DriveTypeeError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Цвет салона:</div>
<div class="col-8">
<input type="text" name="CabinColor" id="CabinColor" value="@Model.CabinColor" />
<span id="CabinColorError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8">
<input type="text" name="Price" id="Price" value="@Model.Price" />
<span id="PriceError" class="text-danger"></span>
</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>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#bundlinglForm').submit(function (event) {
var HelpDevice = $('#HelpDevice').val();
var CabinColor = $('#CabinColor').val();
var DriveType = $('#DriveType').val();
var Price = $('#Price').val();
var isValid = true;
$('#PriceError').text('');
$('#HelpDeviceError').text('');
$('#CabinColorError').text('');
$('#DriveTypeError').text('');
if (isNaN(price) || cost <= 0) {
$('#PriceError').text('Цена должна быть положительным числом.');
isValid = false;
}
if (!isValid) {
event.preventDefault();
}
});
});
</script>

View File

@ -1,21 +1,23 @@
@{
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="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>
<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>

View File

@ -0,0 +1,46 @@
@using CarCenterContracts.ViewModels;
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "FeatureCreate";
}
<div class="text-center">
<h2 class="display-4">Создание особенности</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Вспомогательные устройства:</div>
<div class="col-8">
<select name="helpDevice" id="helpDevice">
@foreach (var value in Enum.GetValues(typeof(HelpDevices)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цвет салона:</div>
<div class="col-8"><input type="text" name="cabinColor" id="cabinColor" /></div>
</div>
<div class="row">
<div class="col-4">Тип привода:</div>
<div class="col-8">
<select name="driveType" id="driveType>
@foreach (var value in Enum.GetValues(typeof(DriveTypes)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></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

@ -0,0 +1,16 @@
@{
ViewData["Title"] = "FeatureDelete";
}
<div class="text-center">
<h2 class="display-4">Удалить особенность</h2>
</div>
<form method="post">
<div class="row">
<div class="col-8">
<select id="feature" name="feature" class="form-control" asp-items="@(new SelectList(@ViewBag.Features,"Id"))"></select>
</div>
</div>
<div class="col-4">
<input type="submit" value="Удалить" class="btn btn-danger" />
</div>
</form>

View File

@ -0,0 +1,52 @@
<!-- Страница обновления особенности. Самой логики нет, она будет в 3 этапе курсовой работы, поэтому пока так. -->
@using CarCenterDataModels.Enums;
@{
ViewData["Title"] = "FeatureUpdate";
}
<div class="text-center">
<h2 class="display-4">Обновление особенности</h2>
</div>
<form method="post">
<div class="row mb-3">
<div class="col-4">Особенность</div>
<div class="col-8">
<select id="feature" name="feature" class="form-control" asp-items="@(new SelectList(@ViewBag.Features,"Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Вспомогательные устройства:</div>
<div class="col-8">
<select name="helpDevice" id="helpDevice">
@foreach (var value in Enum.GetValues(typeof(HelpDevices)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цвет салона:</div>
<div class="col-8"><input type="text" name="cabinColor" id="cabinColor" /></div>
</div>
<div class="row">
<div class="col-4">Тип привода:</div>
<div class="col-8">
<select name="druveType" id="driveType>
@foreach (var value in Enum.GetValues(typeof(DriveTypes)))
{
<option value="@value">@value</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="price" id="price" /></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

@ -0,0 +1,60 @@
@using CarCenterContracts.ViewModels;
@model List<FeatureViewModel>
@{
ViewData["Title"] = "Features";
}
<div class="text-center">
<h1 class="display-4">Особенность</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h2 class="display-4">Надо войти в аккаунт.</h2>
return;
}
<p>
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать особенность</a>
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить особенность</a>
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить особенность</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Вспомогательные устройства
</th>
<th>
Цвет салона
</th>
<th>
Тип привода
</th>
<th>
Цена
</th>
</tr>
</thead>
<tbody>
@foreach (var feature in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => feature.HelpDevice)
</td>
<td>
@Html.DisplayFor(modelItem => feature.CabinColor)
</td>
<td>
@Html.DisplayFor(modelItem => feature.DriveType)
</td>
<td>
@Html.DisplayFor(modelItem => feature.Price)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -3,14 +3,5 @@
}
<div class="text-center">
<h1 class="display-4">Главное меню</h1>
<div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexBundling">Комплектации</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexFeature">Особенности</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexCar">Автомобили</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>
<img src="./Images/cat.png" alt="logo">
</div>

View File

@ -1,82 +0,0 @@
@using CarCenterContracts.ViewModels;
@model List<BundlingViewModel>
@{
ViewData["Title"] = "Bundlings";
}
<div class="text-center">
<h1 class="display-4">Комплектации</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateBundling" asp-route-id="0">Создать комплектацию</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Пакет оборудования
</th>
<th>
Пакет шин
</th>
<th>
Пакет инструментов
</th>
<th>
Цена
</th>
<th>
Изменить комплектацию
</th>
<th>
Удалить комплектацию
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.EquipmentPackage)
</td>
<td>
@Html.DisplayFor(modelItem => item.TirePackage)
</td>
<td>
@Html.DisplayFor(modelItem => item.ToolKit)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
<a asp-action="CreateBundling" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,82 +0,0 @@
@using CarCenterContracts.ViewModels;
@model List<CarViewModel>
@{
ViewData["Title"] = "Cars";
}
<div class="text-center">
<h1 class="display-4">Автомобили</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateCar" asp-route-id="0">Создать автомобиль</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Марка
</th>
<th>
Модель
</th>
<th>
Класс
</th>
<th>
ВИН-номер
</th>
<th>
Изменить автомобиль
</th>
<th>
Удалить автомобиль
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.CarBrand)
</td>
<td>
@Html.DisplayFor(modelItem => item.Model)
</td>
<td>
@Html.DisplayFor(modelItem => item.CarClass)
</td>
<td>
@Html.DisplayFor(modelItem => item.VINnumber)
</td>
<td>
<a asp-action="CreateCar" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,82 +0,0 @@
@using CarCenterContracts.ViewModels;
@model List<FeatureViewModel>
@{
ViewData["Title"] = "Features";
}
<div class="text-center">
<h1 class="display-4">Особенности</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateFeature" asp-route-id="0">Создать особенность</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Вспомогательное устройтсво
</th>
<th>
Цвет кабины
</th>
<th>
Тип привода
</th>
<th>
Цена
</th>
<th>
Изменить изделие
</th>
<th>
Удалить изделие
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.HelpDevice)
</td>
<td>
@Html.DisplayFor(modelItem => item.CabinColor)
</td>
<td>
@Html.DisplayFor(modelItem => item.DriveType)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
<a asp-action="CreateFeature" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,10 +0,0 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</div>
</div>

View File

@ -1,112 +0,0 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Имя:</div>
<div class="col-8">
<input type="text" name="name" id="name" value="@Model.Name" />
<span id="nameError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Фамилия</div>
<div class="col-8">
<input type="text" name="surname" id="surname" value="@Model.Surname" />
<span id="surnameError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Отчество:</div>
<div class="col-8">
<input type="text" name="patronymic" id="patronymic" value="@Model.Patronymic" />
<span id="patronymicError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Почта:</div>
<div class="col-8">
<input type="email" name="email" id="email" value="@Model.Email" />
<span id="emailError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Телефон:</div>
<div class="col-8">
<input type="text" name="phone" id="phone" value="@Model.PhoneNumber" />
<span id="phoneError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8">
<input type="password" name="password1" id="password1" value="@Model.Password" />
<span id="password1Error" class="text-danger"></span>
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#registerForm').submit(function (event) {
var name = $('#name').val();
var surname = $('#surname').val();
var patronymic = $('#patronymic').val();
var phone = $('#phone').val();
var email = $('#email').val();
var password1 = $('#password1').val();
var isValid = true;
$('#nameError').text('');
$('#surnameError').text('');
$('#patronymicError').text('');
$('#emailError').text('');
$('#phoneError').text('');
$('#password1Error').text('');
// Валидация имени
if (name.length < 2 || name.length > 50) {
$('#nameError').text('Имя должно быть от 2 до 50 символов.');
isValid = false;
}
// Валидация фамилии
if (surname.length < 2 || surname.length > 50) {
$('#surnameError').text('Фамилия должно быть от 2 до 50 символов.');
isValid = false;
}
// Валидация отчества
if (patronymic.length < 2 || patronymic.length > 50) {
$('#patronymicError').text('Отчество должен быть от 2 до 50 символов.');
isValid = false;
}
// Валидация телефона
if (phone.length < 1 || phone.length > 12) {
$('#phoneError').text('Телефон должен быть от 1 до 12 символов.');
isValid = false;
}
// Валидация почты
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (!emailPattern.test(email)) {
$('#emailError').text('Неверный формат почты.');
isValid = false;
}
// Валидация пароля
if (password1.length < 8 || password1.length > 20) {
$('#password1Error').text('Пароль должен быть от 8 до 20 символов.');
isValid = false;
}
if (!isValid) {
event.preventDefault();
}
});
});
</script>

View File

@ -7,125 +7,33 @@
<form method="post">
<div class="row">
<div class="col-4">Имя:</div>
<div class="col-8">
<input type="text" name="name" id="name" />
<span id="nameError" class="text-danger"></span>
</div>
<div class="col-8"><input type="text" name="name" /></div>
</div>
<div class="row">
<div class="col-4">Фамилия</div>
<div class="col-8">
<input type="text" name="surname" id="surname" />
<span id="surnameError" class="text-danger"></span>
</div>
<div class="col-4">Фамилия:</div>
<div class="col-8"><input type="text" name="surname" /></div>
</div>
<div class="row">
<div class="col-4">Отчество:</div>
<div class="col-8">
<input type="text" name="patronymic" id="patronymic" />
<span id="patronymicError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Почта:</div>
<div class="col-8">
<input type="email" name="email" id="email" />
<span id="emailError" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-4">Телефон:</div>
<div class="col-8">
<input type="text" name="phone" id="phone" />
<span id="phoneError" class="text-danger"></span>
</div>
<div class="col-8"><input type="text" name="patronymic" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8">
<input type="password" name="password1" id="password1" />
<span id="password1Error" class="text-danger"></span>
</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">Повтор пароля:</div>
<div class="col-8">
<input type="password" name="password2" id="password2" />
<span id="password2Error" class="text-danger"></span>
</div>
<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="text" name="phone" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
<div class="col-4">
<input type="submit" value="Регистрация"
class="btn btn-primary" />
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#registerForm').submit(function (event) {
var name = $('#name').val();
var surname = $('#surname').val();
var patronymic = $('#patronymic').val();
var phone = $('#phone').val();
var email = $('#email').val();
var password1 = $('#password1').val();
var password2 = $('#password2').val();
var isValid = true;
$('#nameError').text('');
$('#surnameError').text('');
$('#patronymicError').text('');
$('#emailError').text('');
$('#phoneError').text('');
$('#password1Error').text('');
$('#password2Error').text('');
// Валидация имени
if (name.length < 2 || name.length > 50) {
$('#nameError').text('Имя должно быть от 2 до 50 символов.');
isValid = false;
}
// Валидация фамилии
if (surname.length < 2 || surname.length > 50) {
$('#surnameError').text('Фамилия должно быть от 2 до 50 символов.');
isValid = false;
}
// Валидация отчества
if (patronymic.length < 2 || patronymic.length > 50) {
$('#patronymicError').text('Отчество должен быть от 2 до 50 символов.');
isValid = false;
}
// Валидация телефона
if (phone.length < 1 || phone.length > 12) {
$('#phoneError').text('Телефон должен быть от 1 до 12 символов.');
isValid = false;
}
// Валидация почты
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (!emailPattern.test(email)) {
$('#emailError').text('Неверный формат почты.');
isValid = false;
}
// Валидация пароля
if (password1.length < 8 || password1.length > 20) {
$('#password1Error').text('Пароль должен быть от 8 до 20 символов.');
isValid = false;
}
// Проверка совпадения паролей
if (password1 !== password2) {
$('#password2Error').text('Пароли не совпадают.');
isValid = false;
}
if (!isValid) {
event.preventDefault();
}
});
});
</script>
</form>

View File

@ -12,8 +12,33 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a asp-controller="Home" asp-action="Index">Главная</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">CarCenterStorekeeperApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Bundlings">Комплектации</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Features">Особенности</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Cars">Машины</a>
</li>
</ul>
</div>
</div>
</nav>
</header>