Игорь, вы не внимательный! :/

This commit is contained in:
Илья Федотов 2024-05-25 17:47:14 +04:00
parent ea17d23db7
commit d50c9f7f85
183 changed files with 75937 additions and 178 deletions

View File

@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopRestAPI", "E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopClientApp", "ElectronicsShopClientApp\ElectronicsShopClientApp.csproj", "{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopShopAssistantApp", "ElectronicsShopShopAssistantApp\ElectronicsShopShopAssistantApp.csproj", "{7AD6BB69-756A-42B2-86EB-28F31A426653}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopShopClientApp", "ElectronicsShopShopClientApp\ElectronicsShopShopClientApp.csproj", "{029A15C5-BBCE-415E-A3EC-80568D54852A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopEmployeeApp", "ElectronicsShopEmployeeApp\ElectronicsShopEmployeeApp.csproj", "{EEDB8074-33B3-409C-A3DD-AF6B403CC907}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -47,10 +49,14 @@ Global
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Release|Any CPU.Build.0 = Release|Any CPU
{7AD6BB69-756A-42B2-86EB-28F31A426653}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AD6BB69-756A-42B2-86EB-28F31A426653}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AD6BB69-756A-42B2-86EB-28F31A426653}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AD6BB69-756A-42B2-86EB-28F31A426653}.Release|Any CPU.Build.0 = Release|Any CPU
{029A15C5-BBCE-415E-A3EC-80568D54852A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{029A15C5-BBCE-415E-A3EC-80568D54852A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{029A15C5-BBCE-415E-A3EC-80568D54852A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{029A15C5-BBCE-415E-A3EC-80568D54852A}.Release|Any CPU.Build.0 = Release|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -23,7 +23,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
_storage = storage;
}
public bool Add(ClientBindingModel model)
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null)
@ -120,8 +120,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
if (element != null && element.Email != model.Email)
{
throw new InvalidOperationException("Клиент с такой почтой уже есть");
}
}
}
}
}
}

View File

@ -93,7 +93,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
}
_logger.LogInformation($"CostItem. ID:{model.ID}.EmployeeID:{model.EmployeeID}.Name:{model.Name}.Price:{model.Price}");
var element = _storage.GetElement(new CostItemSearchModel { ID = model.ID });
if (element != null && element.EmployeeID != model.EmployeeID)
if (element != null && element.ID != model.EmployeeID)
{
throw new InvalidOperationException("Продукт с таким названием уже есть");
}

View File

@ -17,14 +17,6 @@
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="text" name="phone number" value="@Model.PhoneNumber"/></div>
</div>
<div class="row">
<div class="col-4">логин:</div>
<div class="col-8"><input type="text" name="fio" value="@Model.Login"/></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>

View File

@ -18,6 +18,6 @@ namespace ElectronicsShopContracts.BindingModels
public double SumPayment { get; set; }
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
}
}

View File

@ -18,6 +18,5 @@ namespace ElectronicsShopContracts.StorageContracts
EmployeeViewModel? Insert(EmployeeBindingModel model);
EmployeeViewModel? Update(EmployeeBindingModel model);
EmployeeViewModel? Delete(EmployeeBindingModel model);
object GetElement(CostItemSearchModel costItemSearchModel);
}
}

View File

@ -20,6 +20,6 @@ namespace ElectronicsShopContracts.ViewModels
public double SumPayment { get; set; }
[DisplayName("Статус оплаты")]
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
}
}

View File

@ -9,12 +9,11 @@ namespace ElectronicsShopDataBaseImplement
protected override void OnConfiguring(DbContextOptionsBuilder
optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
if (optionsBuilder.IsConfigured == false) {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Product> Products { set; get; }
public virtual DbSet<Order> Orders { set; get; }

View File

@ -34,7 +34,11 @@ namespace ElectronicsShopDataBaseImplement.Implements
(model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
}
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
public object GetElement(CostItemSearchModel costItemSearchModel) {
throw new NotImplementedException();
}
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{
if (string.IsNullOrEmpty(model.Login))
{

View File

@ -0,0 +1,204 @@
// <auto-generated />
using System;
using ElectronicsShopDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20240525133056_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("CostItems");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("EmployeeFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Employees");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ClientID")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<int?>("EmployeeID")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Orders");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrdersID")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<int>("_orderID")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductID");
b.HasIndex("_orderID");
b.ToTable("OrderProducts");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("CostItemID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Products");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{
b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product")
.WithMany()
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order")
.WithMany("Products")
.HasForeignKey("_orderID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("_order");
b.Navigation("_product");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,151 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.ID);
});
migrationBuilder.CreateTable(
name: "CostItems",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeID = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CostItems", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Sum = table.Column<double>(type: "float", nullable: false),
ClientID = table.Column<int>(type: "int", nullable: false),
EmployeeID = table.Column<int>(type: "int", nullable: true),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
CostItemID = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.ID);
});
migrationBuilder.CreateTable(
name: "OrderProducts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrdersID = table.Column<int>(type: "int", nullable: false),
ProductID = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
_orderID = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderProducts", x => x.Id);
table.ForeignKey(
name: "FK_OrderProducts_Orders__orderID",
column: x => x._orderID,
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderProducts_Products_ProductID",
column: x => x.ProductID,
principalTable: "Products",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_OrderProducts__orderID",
table: "OrderProducts",
column: "_orderID");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts_ProductID",
table: "OrderProducts",
column: "ProductID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "CostItems");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "OrderProducts");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Products");
}
}
}

View File

@ -0,0 +1,201 @@
// <auto-generated />
using System;
using ElectronicsShopDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
[DbContext(typeof(Database))]
partial class DatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("CostItems");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("EmployeeFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Employees");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ClientID")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<int?>("EmployeeID")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Orders");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrdersID")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<int>("_orderID")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductID");
b.HasIndex("_orderID");
b.ToTable("OrderProducts");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("CostItemID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Products");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{
b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product")
.WithMany()
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order")
.WithMany("Products")
.HasForeignKey("_orderID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("_order");
b.Navigation("_product");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -14,7 +14,8 @@ namespace ElectronicsShopDataBaseImplement.Models
public class CostItem : ICostItemModel
{
public int ID { get; set; }
[ForeignKey("ClientID")]
[ForeignKey("EmployeeID")]
public int EmployeeID { get; set; }
[Required]
public string Name { get; set; }= string.Empty;

View File

@ -24,15 +24,15 @@ namespace ElectronicsShopDataBaseImplement.Models
public int? EmployeeID { get; set; }
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
[Required]
public Dictionary<int, (IProductModel, int)> ProductList { get; set; } = new();
public Dictionary<int, (IProductModel, int)>? _productList = null;
[NotMapped]
public Dictionary<int, (IProductModel, int)> _productList
public Dictionary<int, (IProductModel, int)> ProductList
{
get {
if (ProductList == null) {
ProductList = Products.ToDictionary(recPC => recPC.ProductID, recPC => (recPC._product as IProductModel, recPC.Count));
if (_productList == null) {
_productList = Products.ToDictionary(recPC => recPC.ProductID, recPC => (recPC._product as IProductModel, recPC.Count));
}
return _productList;
}
@ -93,5 +93,5 @@ namespace ElectronicsShopDataBaseImplement.Models
}).ToList()
*/
};
}
}
}

View File

@ -23,7 +23,7 @@ namespace ElectronicsShopDataBaseImplement.Models
[Required]
public double SumPayment { get; set; }
[Required]
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
public static Payment? Create(PaymentBindingModel? model)
{
if (model == null)

View File

@ -0,0 +1,41 @@
using ElectronicsShopContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace ElectronicsShopEmployeeApp {
public class APIEmployee {
private static readonly HttpClient _employee = new();
public static EmployeeViewModel? Employee { get; set; } = null;
public static void Connect(IConfiguration configuration) {
_employee.BaseAddress = new Uri(configuration["IPAddress"]);
_employee.DefaultRequestHeaders.Accept.Clear();
_employee.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequset<T>(string requestUrl) {
var response = _employee.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode) {
return JsonConvert.DeserializeObject<T>(result);
}
else {
throw new Exception(result);
}
}
public static void PostRequest<T>(string requstUrl, T model) {
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _employee.PostAsync(requstUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode) {
throw new Exception(result);
}
}
}
}

View File

@ -0,0 +1,101 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopEmployeeApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace ElectronicsShopEmployeeApp.Controllers {
public class HomeController : Controller {
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger) {
_logger = logger;
}
public IActionResult Index() {
if (APIEmployee.Employee == null) {
return Redirect("~/Home/Enter");
}
return View(APIEmployee.GetRequset<List<ProductViewModel>>($"api/main/getproducts"));
}
[HttpGet]
public IActionResult Privacy() {
if (APIEmployee.Employee == null) {
return Redirect("~/Home/Enter");
}
return View(APIEmployee.Employee);
}
[HttpPost]
public void Privacy(string login, string password, string fio) {
if (APIEmployee.Employee == null) {
throw new Exception("Âõîä òîëüêî äëÿ àâòîðèçîâàííûõ");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) {
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü, ÔÈÎ");
}
APIEmployee.PostRequest("api/employee/updatedata", new EmployeeBindingModel {
ID = APIEmployee.Employee.ID,
EmployeeFIO = fio,
Login = login,
Password = password,
});
APIEmployee.Employee.EmployeeFIO = fio;
APIEmployee.Employee.Login = login;
APIEmployee.Employee.Password = password;
Response.Redirect("Index");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public IActionResult Enter() {
return View();
}
public void Enter(string login, string password) {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) {
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
}
APIEmployee.Employee = APIEmployee.GetRequset<EmployeeViewModel>($"api/employee/login/login={login}&password={password}");
if (APIEmployee.Employee == null) {
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
}
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Register() {
return View();
}
public void Register(string login, string password, string fio) {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) {
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
}
APIEmployee.PostRequest("api/employee/register", new EmployeeBindingModel {
EmployeeFIO = fio,
Login = login,
Password = password
});
Response.Redirect("Enter");
return;
}
[HttpGet]
public IActionResult Create() {
ViewBag.Orders = APIEmployee.GetRequset<List<OrderViewModel>>("api/main/getproductlist");
return View();
}
public void Create(OrderBindingModel order) {
throw new NotImplementedException();
}
}
}

View File

@ -6,6 +6,10 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
</ItemGroup>

View File

@ -0,0 +1,7 @@
namespace ElectronicsShopEmployeeApp.Models {
public class ErrorViewModel {
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,35 @@
using ElectronicsShopEmployeeApp;
namespace ElectronicsShopUserApp {
public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIEmployee.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
}
}
}

View File

@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62052",
"sslPort": 44365
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5044",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7221;http://localhost:5044",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,3 @@
@{
ViewData["Title"] = "Create";
}

View File

@ -7,8 +7,8 @@
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
<div class="col-4">Почта:</div>
<div class="col-8"><input type="text" name="Login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>

View File

@ -0,0 +1,63 @@
@using ElectronicsShopContracts.ViewModels
@model List<ProductViewModel>
@{
ViewData["Title"] = "Home Page";
}
<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="Create">Создать продукта</a>
</p>
<table class="table">
<thead>
<th>
<th>
Номер продукта
</th>
<th>
Статья затрат
</th>
<th>
Название продукта
</th>
<th>
Сумма
</th>
<th>
Статус оплаты
</th>
</th>
</thead>
<tbody>
@foreach (var item in Model) {
<th>
<th>
@Html.DisplayFor(modelItem => item.ID)
</th>
<th>
@Html.DisplayFor(modelItem => item.CostItemID)
</th>
<th>
@Html.DisplayFor(modelItem => item.ProductName)
</th>
<th>
@Html.DisplayFor(modelItem => item.Price)
</th>
</th>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -7,20 +7,16 @@
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
<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-4">Имя:</div>
<div class="col-8"><input type="text" name="Имя" /></div>
</div>
<div class="row">
<div class="col-4">Фамилия:</div>
<div class="col-8"><input type="text" name="Фамилия" /></div>
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="fio" /></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ElectronicsShopEmployeeApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/ElectronicsShopEmployeeApp.styles.css" asp-append-version="true" />
</head>
<body>
<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">ElectronicsShopEmployeeApp</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 flex-sm-row-reverse">
<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="Privacy">Личные данные</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>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - ElectronicsShopEmployeeApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,3 @@
@using ElectronicsShopEmployeeApp
@using ElectronicsShopEmployeeApp.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
// порт -> Свойства/отладка/пользовательский ин./URL адресс
"IPAddress": "http://localhost:5176/"
}

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,33 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller {
private readonly ILogger _logger;
public ClientController(ILogger<ClientController> logger) {
_logger = logger;
}
[HttpGet]
public ClientViewModel? Login(string email, string password) {
return null;
}
[HttpPost]
public void Register(ClientBindingModel model) {
return;
}
[HttpPost]
public void UpdateData(ClientBindingModel model) {
return;
}
}
}

View File

@ -0,0 +1,33 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class EmployeeController : Controller {
private readonly ILogger _logger;
public EmployeeController(ILogger<EmployeeController> logger) {
_logger = logger;
}
[HttpGet]
public EmployeeViewModel? Login(string login, string password) {
return null;
}
[HttpPost]
public void Register(EmployeeBindingModel model) {
return;
}
[HttpPost]
public void UpdateData(EmployeeBindingModel model) {
return;
}
}
}

View File

@ -1,9 +1,48 @@
using Microsoft.AspNetCore.Mvc;
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopResrAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class MainController : Controller {
public IActionResult Index() {
return View();
private readonly ILogger _logger;
public MainController(ILogger<MainController> logger) {
_logger = logger;
}
[HttpGet]
public List<ProductViewModel>? GetProductList() {
//tdoo
return null;
}
[HttpGet]
public ProductViewModel? GetProduct(int ProductID) {
return null;
}
// клиент должен получать свои заказы
// сотрудник должен получать все заказы
[HttpGet]
public List<OrderViewModel>? GetOrders(int? userID = null) {
return null;
}
[HttpPost]
public void CreateOrder(OrderBindingModel model) {
return;
}
[HttpPost]
public void CreateProduct(OrderBindingModel model) {
return;
}
//Мейби нужны будут удаления, обновления, выбор конкретного заказа или продукта. Короче потом....
}
}

View File

@ -1,9 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopResrAPI.Controllers {
public class UserController : Controller {
public IActionResult Index() {
return View();
}
}
}

View File

@ -11,4 +11,8 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -2,12 +2,14 @@ using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
//todo logger!!!
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(x => x.SwaggerDoc("v1", new OpenApiInfo { Title = "ElectronicsShopResrAPI", Version = "v1" }));
builder.Services.AddSwaggerGen(x => x.SwaggerDoc("v1", new OpenApiInfo { Title = "ElectronicsShopRestAPI", Version = "v1" }));
var app = builder.Build();
@ -15,7 +17,7 @@ var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "ElectronicsShopResrAPI v1"));
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "ElectronicsShopRestAPI v1"));
}
app.UseHttpsRedirection();

Some files were not shown because too many files have changed in this diff Show More