сделал страницу комплектаций, фулл юзера
This commit is contained in:
parent
6acd4ab8a1
commit
0ff1141437
@ -100,7 +100,15 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет телефона", nameof(model.PhoneNumber));
|
||||
}
|
||||
_logger.LogInformation("Storekeeper. Storekeeper:Id:{ Id}.PhoneNumber:{ PhoneNumber}", model.Id, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ 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; }
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ namespace CarCenterContracts.SearchModels
|
||||
public class BundlingSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? StorekeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ namespace CarCenterContracts.SearchModels
|
||||
public class StorekeeperSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Password { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ namespace CarCenterContracts.ViewModels
|
||||
public class BundlingViewModel : IBundlingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Пакет оборудования")]
|
||||
public int StorekeeperId { get; set; }
|
||||
[DisplayName("Пакет оборудования")]
|
||||
public EquipmentPackage EquipmentPackage { get; set; }
|
||||
[DisplayName("Пакет шин")]
|
||||
public TirePackage TirePackage { get; set; }
|
||||
|
@ -23,10 +23,10 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
public List<BundlingViewModel> GetFilteredList(BundlingSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
if (model.StorekeeperId.HasValue)
|
||||
{
|
||||
return context.Bundlings
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Where(x => x.StorekeeperId == model.StorekeeperId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -42,12 +42,9 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
public StorekeeperViewModel? GetElement(StorekeeperSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue) { return null; }
|
||||
if (model.Id.HasValue)
|
||||
return context.Storekeepers
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
return null;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
[Migration("20240428140324_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20240528131936_InitialCreate2")]
|
||||
partial class InitialCreate2
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -38,6 +38,9 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TirePackage")
|
||||
.HasColumnType("integer");
|
||||
|
@ -6,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class InitialCreate2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@ -16,6 +16,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),
|
||||
EquipmentPackage = table.Column<int>(type: "integer", nullable: false),
|
||||
TirePackage = table.Column<int>(type: "integer", nullable: false),
|
||||
ToolKit = table.Column<int>(type: "integer", nullable: false),
|
@ -36,6 +36,9 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TirePackage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
@ -16,7 +16,8 @@ namespace CarCenterDatabaseImplement.Models
|
||||
public class Bundling : IBundlingModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int StorekeeperId { get; set; }
|
||||
[Required]
|
||||
public EquipmentPackage EquipmentPackage { get; set; } = EquipmentPackage.Неизвестно;
|
||||
[Required]
|
||||
public TirePackage TirePackage { get; set; } = TirePackage.Неизвестно;
|
||||
@ -37,6 +38,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return new Bundling()
|
||||
{
|
||||
Id = model.Id,
|
||||
StorekeeperId = model.StorekeeperId,
|
||||
EquipmentPackage = model.EquipmentPackage,
|
||||
TirePackage = model.TirePackage,
|
||||
ToolKit = model.ToolKit,
|
||||
@ -48,6 +50,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return new Bundling
|
||||
{
|
||||
Id = model.Id,
|
||||
StorekeeperId=model.StorekeeperId,
|
||||
EquipmentPackage = model.EquipmentPackage,
|
||||
TirePackage = model.TirePackage,
|
||||
ToolKit = model.ToolKit,
|
||||
@ -60,6 +63,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
StorekeeperId = model.StorekeeperId;
|
||||
EquipmentPackage = model.EquipmentPackage;
|
||||
TirePackage = model.TirePackage;
|
||||
ToolKit = model.ToolKit;
|
||||
@ -68,6 +72,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
public BundlingViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StorekeeperId = StorekeeperId,
|
||||
EquipmentPackage = EquipmentPackage,
|
||||
TirePackage = TirePackage,
|
||||
ToolKit = ToolKit,
|
||||
|
@ -53,6 +53,9 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Name = model.Name;
|
||||
Surname = model.Surname;
|
||||
Patronymic = model.Patronymic;
|
||||
Email = model.Email;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
|
@ -1,94 +1,155 @@
|
||||
using CarCenterStorekeeperApp.Models;
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterStorekeeperApp.Models;
|
||||
using ImplementerApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StorekeeperApp;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
|
||||
namespace CarCenterStorekeeperApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly StorekeeperData _data;
|
||||
public HomeController(ILogger<HomeController> logger, StorekeeperData data)
|
||||
{
|
||||
_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()
|
||||
{
|
||||
return View();
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Bundlings()
|
||||
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()
|
||||
{
|
||||
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
|
||||
{
|
||||
if (_data.UpdateBundling(model))
|
||||
return RedirectToAction("IndexBundling");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult BundlingCreate()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult BundlingDelete()
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
if (IsLoggedIn)
|
||||
return View(UserStorekeeper.user);
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult BundlingUpdate()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Features()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult FeatureCreate()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
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)]
|
||||
[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 Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
@ -2,6 +2,7 @@ using CarCenterBusinessLogic.BusinessLogics;
|
||||
using CarCenterContracts.BusinessLogicsContracts;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterDatabaseImplement.Implements;
|
||||
using StorekeeperApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -27,6 +28,7 @@ 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();
|
||||
|
||||
|
153
CarCenter/CarCenterStorekeeperApp/StorekeeperData.cs
Normal file
153
CarCenter/CarCenterStorekeeperApp/StorekeeperData.cs
Normal file
@ -0,0 +1,153 @@
|
||||
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 IProductionLogic _productionLogic;
|
||||
private readonly IProductLogic _productLogic;
|
||||
private readonly IMachineLogic _machineLogic;
|
||||
private readonly IWorkshopLogic _workshopLogic;*/
|
||||
|
||||
public StorekeeperData(ILogger<StorekeeperData> logger, IStorekeeperLogic storekeeperLogic, IBundlingLogic bundlingLogic/* IProductionLogic productionLogic, IProductLogic productLogic, IMachineLogic machineLogic, IWorkshopLogic workshopLogic*/)
|
||||
{
|
||||
_logger = logger;
|
||||
_storekeeperLogic = storekeeperLogic;
|
||||
_bundlingLogic = bundlingLogic;
|
||||
/* _productionLogic = productionLogic;
|
||||
_productLogic = productLogic;
|
||||
_machineLogic = machineLogic;
|
||||
_workshopLogic = workshopLogic;*/
|
||||
}
|
||||
|
||||
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<ProductViewModel>? GetProducts(int userId)
|
||||
{
|
||||
return _productLogic.ReadList(new ProductSearchModel() { UserId = userId });
|
||||
}
|
||||
public ProductViewModel? GetProduct(int id)
|
||||
{
|
||||
return _productLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public bool UpdateProduct(ProductBindingModel model)
|
||||
{
|
||||
return _productLogic.Update(model);
|
||||
}
|
||||
public bool DeleteProduct(int productId)
|
||||
{
|
||||
return _productLogic.Delete(new() { Id = productId });
|
||||
}
|
||||
public bool CreateProduct(ProductBindingModel model)
|
||||
{
|
||||
return _productLogic.Create(model);
|
||||
}
|
||||
|
||||
public List<ProductionViewModel>? GetProductions(int userId)
|
||||
{
|
||||
return _productionLogic.ReadList(new() { UserId = userId });
|
||||
}
|
||||
public ProductionViewModel? GetProduction(int id)
|
||||
{
|
||||
return _productionLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public bool CreateProduction(ProductionBindingModel model)
|
||||
{
|
||||
return _productionLogic.Create(model);
|
||||
}
|
||||
public bool UpdateProduction(ProductionBindingModel model)
|
||||
{
|
||||
return _productionLogic.Update(model);
|
||||
}
|
||||
public bool DeleteProduction(int productionId)
|
||||
{
|
||||
return _productionLogic.Delete(new() { Id = productionId });
|
||||
}
|
||||
|
||||
public List<MachineViewModel>? GetMachines()
|
||||
{
|
||||
return _machineLogic.ReadList(null);
|
||||
}
|
||||
|
||||
public List<BundlingTimeReport> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
|
||||
{
|
||||
var bundlings = _bundlingLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, UserId = UserId });
|
||||
if (bundlings == null)
|
||||
return new();
|
||||
List<BundlingTimeReport> bundlingTimeReports = new List<BundlingTimeReport>();
|
||||
foreach (var bundling in bundlings)
|
||||
{
|
||||
var report = new BundlingTimeReport();
|
||||
report.BundlingName = bundling.Name;
|
||||
var products = _productLogic.ReadList(new() { BundlingId = bundling.Id, UserId = UserId });
|
||||
if (products != null)
|
||||
report.Products = products.Select(p => p.Name).ToList();
|
||||
var productions = _productionLogic.ReadList(new() { BundlingId = bundling.Id, UserId = UserId });
|
||||
if (productions != null)
|
||||
report.Productions = productions.Select(p => p.Name).ToList();
|
||||
bundlingTimeReports.Add(report);
|
||||
}
|
||||
return bundlingTimeReports;
|
||||
}
|
||||
|
||||
public List<BundlingWorkshopReportViewModel>? GetWorkshopReports(List<int> bundlings)
|
||||
{
|
||||
List<BundlingWorkshopReportViewModel> reports = new();
|
||||
foreach (int i in bundlings)
|
||||
{
|
||||
BundlingWorkshopReportViewModel report = new();
|
||||
var bundling = _bundlingLogic.ReadElement(new() { Id = i });
|
||||
report.BundlingName = bundling!.Name;
|
||||
var workshops = _workshopLogic.ReadList(new() { BundlingId = i });
|
||||
if (workshops != null)
|
||||
report.WorkShops = workshops.Select(w => w.Title).ToList();
|
||||
reports.Add(report);
|
||||
}
|
||||
return reports;
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
9
CarCenter/CarCenterStorekeeperApp/UserStorekeeper.cs
Normal file
9
CarCenter/CarCenterStorekeeperApp/UserStorekeeper.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using CarCenterContracts.ViewModels;
|
||||
|
||||
namespace ImplementerApp
|
||||
{
|
||||
public static class UserStorekeeper
|
||||
{
|
||||
public static StorekeeperViewModel? user { get; set; }
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
@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>
|
@ -1,16 +0,0 @@
|
||||
@{
|
||||
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>
|
@ -1,57 +0,0 @@
|
||||
<!-- Страница обновления комплектации. Самой логики нет, она будет в 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>
|
@ -1,60 +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)
|
||||
{
|
||||
<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>
|
@ -0,0 +1,86 @@
|
||||
@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">
|
||||
@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">
|
||||
@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">
|
||||
@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>
|
@ -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>
|
@ -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="IndexBundling">Комплектации</a>
|
||||
@* <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduct">Изделия</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduction">Производства</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>
|
||||
|
@ -0,0 +1,82 @@
|
||||
@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>
|
@ -0,0 +1,10 @@
|
||||
@{
|
||||
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>
|
116
CarCenter/CarCenterStorekeeperApp/Views/Home/Privacy.cshtml
Normal file
116
CarCenter/CarCenterStorekeeperApp/Views/Home/Privacy.cshtml
Normal file
@ -0,0 +1,116 @@
|
||||
@{
|
||||
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>
|
||||
<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 () {
|
||||
$('#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>
|
@ -7,33 +7,125 @@
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8"><input type="text" name="name" /></div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="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" /></div>
|
||||
<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>
|
||||
<div class="row">
|
||||
<div class="col-4">Отчество:</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="password" /></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" /></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" /></div>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</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>
|
||||
|
@ -12,33 +12,8 @@
|
||||
<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 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>
|
||||
<a asp-controller="Home" asp-action="Index">Главная</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
Loading…
Reference in New Issue
Block a user