Compare commits
2 Commits
82cc504aba
...
f461b880dd
Author | SHA1 | Date | |
---|---|---|---|
f461b880dd | |||
24578ea1ee |
@ -1,49 +1,55 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterDataModels", "AutoCenterDataModels\AutoCenterDataModels.csproj", "{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterContracts", "AutoCenterContracts\AutoCenterContracts.csproj", "{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterDatabaseImplement", "AutoCenterDatabaseImplement\AutoCenterDatabaseImplement.csproj", "{617B8C58-1F96-44A5-9EE6-A78EA441CA66}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterBusinessLogic", "AutoCenterBusinessLogic\AutoCenterBusinessLogic.csproj", "{FFB35620-52C9-46A7-8607-E1CA5A70D80A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterRestApi", "AutoCenterRestApi\AutoCenterRestApi.csproj", "{2FE0682F-5405-4548-99E5-8AB155DF50E0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D4AA40EB-6CB9-4650-85A1-035B23139ABF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterDataModels", "AutoCenterDataModels\AutoCenterDataModels.csproj", "{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterContracts", "AutoCenterContracts\AutoCenterContracts.csproj", "{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterDatabaseImplement", "AutoCenterDatabaseImplement\AutoCenterDatabaseImplement.csproj", "{617B8C58-1F96-44A5-9EE6-A78EA441CA66}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterBusinessLogic", "AutoCenterBusinessLogic\AutoCenterBusinessLogic.csproj", "{FFB35620-52C9-46A7-8607-E1CA5A70D80A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterRestApi", "AutoCenterRestApi\AutoCenterRestApi.csproj", "{2FE0682F-5405-4548-99E5-8AB155DF50E0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCenterUserApp", "AutoCenterUserApp\AutoCenterUserApp.csproj", "{0EBAAE5A-BAF0-45C4-BB9E-541AB5D303BA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EAE9694C-31B4-4AD0-9FAC-99BBD4F44236}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3458E50C-D0E1-4CC5-B7F2-308C38CA55E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{617B8C58-1F96-44A5-9EE6-A78EA441CA66}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FFB35620-52C9-46A7-8607-E1CA5A70D80A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2FE0682F-5405-4548-99E5-8AB155DF50E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0EBAAE5A-BAF0-45C4-BB9E-541AB5D303BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0EBAAE5A-BAF0-45C4-BB9E-541AB5D303BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0EBAAE5A-BAF0-45C4-BB9E-541AB5D303BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0EBAAE5A-BAF0-45C4-BB9E-541AB5D303BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D4AA40EB-6CB9-4650-85A1-035B23139ABF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,110 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CarBrandLogic : ICarBrandLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarBrandStorage _CarBrandStorage;
|
||||
public CarBrandLogic(ILogger<CarBrandLogic> logger, ICarBrandStorage CarBrandStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_CarBrandStorage = CarBrandStorage;
|
||||
}
|
||||
public List<CarBrandViewModel>? ReadList(CarBrandSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("CarBrand ReadList. Name:{Name}. Id:{Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _CarBrandStorage.GetFullList() :
|
||||
_CarBrandStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public CarBrandViewModel? ReadElement(CarBrandSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("CarBrand ReadElement. Name:{Name}. Id:{Id}", model?.Name, model?.Id);
|
||||
var element = _CarBrandStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(CarBrandBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_CarBrandStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("CarBrand Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(CarBrandBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_CarBrandStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("CarBrand Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(CarBrandBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_CarBrandStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("CarBrand Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(CarBrandBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия бренда",
|
||||
nameof(model.Id));
|
||||
}
|
||||
_logger.LogInformation("CarBrand. Name:{Name}. Id:{Id}", model?.Name, model?.Id);
|
||||
var element = _CarBrandStorage.GetElement(new CarBrandSearchModel
|
||||
{
|
||||
Name = model.Name,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такой бренд уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. CarName:{CarName}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _CarStorage.GetFullList() : _CarStorage.GetFilteredList(model);
|
||||
|
||||
@ -115,16 +114,11 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет названия автомобиля", nameof(model.Name));
|
||||
}
|
||||
|
||||
if (model.BrandId < 1)
|
||||
{
|
||||
throw new ArgumentNullException("Нет бренда автомобиля", nameof(model.BrandId));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Car. CarName:{CarName}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var element = _CarStorage.GetElement(new CarSearchModel
|
||||
{
|
||||
BrandId = model.BrandId,
|
||||
Name = model.Name
|
||||
});
|
||||
|
||||
|
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<EquipmentViewModel>? ReadList(EquipmentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Equipment:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _EquipmentStorage.GetFullList() : _EquipmentStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<PresellingWorkViewModel>? ReadList(PresellingWorkSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. PresellingWork:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _PresellingWorkStorage.GetFullList() : _PresellingWorkStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -72,7 +72,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
}
|
||||
public List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Purchase: Id:{Id}", model.Id);
|
||||
|
||||
var list = model == null ? _PurchaseStorage.GetFullList() : _PurchaseStorage.GetFilteredList(model);
|
||||
|
||||
@ -109,11 +108,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.ShopId < 1)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор магазина", nameof(model.Id));
|
||||
}
|
||||
if (model.UserId < 1)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор пользователя", nameof(model.Id));
|
||||
@ -123,7 +117,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
var element = _PurchaseStorage.GetElement(new PurchaseSearchModel
|
||||
{
|
||||
ShopId = model.ShopId,
|
||||
Date = model.Date,
|
||||
IsCashPaid = model.IsCashPaid,
|
||||
UserId = model.UserId
|
||||
|
@ -1,138 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopStorage _ShopStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage ShopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_ShopStorage = ShopStorage;
|
||||
}
|
||||
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_ShopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_ShopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. Shop:{Address}.Id:{Id}", model.Address, model.Id);
|
||||
|
||||
var element = _ShopStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Shop:{Address}.Id:{Id}", model?.Address, model?.Id);
|
||||
|
||||
var list = model == null ? _ShopStorage.GetFullList() : _ShopStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_ShopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address));
|
||||
}
|
||||
|
||||
|
||||
_logger.LogInformation("Shop. Shop:{Address}.Id:{Id}", model.Address, model.Id);
|
||||
|
||||
var element = _ShopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
Address = model.Address
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такой магазин уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. UserEmail:{UserFIO}.Id:{Id}", model.Email, model.Id);
|
||||
|
||||
var list = model == null ? _UserStorage.GetFullList() : _UserStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace AutoCenterBusinessLogic.BusinessLogics
|
||||
|
||||
public List<WishViewModel>? ReadList(WishSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Wish:{Name}.Id:{Id}", model.Name, model.Id);
|
||||
|
||||
var list = model == null ? _WishStorage.GetFullList() : _WishStorage.GetFilteredList(model);
|
||||
|
||||
|
@ -10,8 +10,7 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class CarBindingModel : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int BrandId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.BindingModels
|
||||
{
|
||||
public class CarBrandBindingModel : ICarBrandModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class EquipmentBindingModel : IEquipmentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace AutoCenterContracts.BindingModels
|
||||
public class PresellingWorkBindingModel : IPresellingWorkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,9 @@ namespace AutoCenterContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public bool IsCashPaid { get; set; }
|
||||
public int ShopId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; } = new();
|
||||
public Dictionary<int, ICarModel> PurchaseCars { get; } = new();
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; set; } = new();
|
||||
public Dictionary<int, ICarModel> PurchaseCars { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Address { get; set; }
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
using AutoCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.BindingModels
|
||||
{
|
||||
public class WishBindingModel : IWishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
using AutoCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.BindingModels
|
||||
{
|
||||
public class WishBindingModel : IWishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICarBrandLogic
|
||||
{
|
||||
List<CarBrandViewModel>? ReadList(CarBrandSearchModel? model);
|
||||
CarBrandViewModel? ReadElement(CarBrandSearchModel model);
|
||||
bool Create(CarBrandBindingModel model);
|
||||
bool Update(CarBrandBindingModel model);
|
||||
bool Delete(CarBrandBindingModel model);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
bool Create(ShopBindingModel model);
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWishLogic
|
||||
{
|
||||
List<WishViewModel>? ReadList(WishSearchModel? model);
|
||||
WishViewModel? ReadElement(WishSearchModel model);
|
||||
bool Create(WishBindingModel model);
|
||||
bool Update(WishBindingModel model);
|
||||
bool Delete(WishBindingModel model);
|
||||
}
|
||||
}
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWishLogic
|
||||
{
|
||||
List<WishViewModel>? ReadList(WishSearchModel? model);
|
||||
WishViewModel? ReadElement(WishSearchModel model);
|
||||
bool Create(WishBindingModel model);
|
||||
bool Update(WishBindingModel model);
|
||||
bool Delete(WishBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class CarBrandSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class CarSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? BrandId { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class CarSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public bool? IsCashPaid { get; set; }
|
||||
public int? ShopId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Address { get; set; }
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class WishSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int? PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.SearchModels
|
||||
{
|
||||
public class WishSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int? PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterContracts.StoragesContracts
|
||||
{
|
||||
public interface ICarBrandStorage
|
||||
{
|
||||
List<CarBrandViewModel> GetFullList();
|
||||
List<CarBrandViewModel> GetFilteredList(CarBrandSearchModel model);
|
||||
CarBrandViewModel? GetElement(CarBrandSearchModel model);
|
||||
CarBrandViewModel? Insert(CarBrandBindingModel model);
|
||||
CarBrandViewModel? Update(CarBrandBindingModel model);
|
||||
CarBrandViewModel? Delete(CarBrandBindingModel model);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -1,21 +1,21 @@
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.StoragesContracts
|
||||
{
|
||||
public interface IWishStorage
|
||||
{
|
||||
List<WishViewModel> GetFullList();
|
||||
List<WishViewModel> GetFilteredList(WishSearchModel model);
|
||||
WishViewModel? GetElement(WishSearchModel model);
|
||||
WishViewModel? Insert(WishBindingModel model);
|
||||
WishViewModel? Update(WishBindingModel model);
|
||||
WishViewModel? Delete(WishBindingModel model);
|
||||
}
|
||||
}
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.StoragesContracts
|
||||
{
|
||||
public interface IWishStorage
|
||||
{
|
||||
List<WishViewModel> GetFullList();
|
||||
List<WishViewModel> GetFilteredList(WishSearchModel model);
|
||||
WishViewModel? GetElement(WishSearchModel model);
|
||||
WishViewModel? Insert(WishBindingModel model);
|
||||
WishViewModel? Update(WishBindingModel model);
|
||||
WishViewModel? Delete(WishBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class CarBrandViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название бренда")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,21 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class CarViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название машины")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public int BrandId { get; set; }
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class CarViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название машины")]
|
||||
public string Name { get; set; }
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class EquipmentViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class EquipmentViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class PresellingWorkViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class PresellingWorkViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class PurchaseViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Метод оплаты")]
|
||||
public bool IsCashPaid { get; set; }
|
||||
public int ShopId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime Date { get; set; }
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; set; } = new();
|
||||
public Dictionary<int, ICarModel> PurchaseCars { get; set; } = new();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class PurchaseViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Метод оплаты")]
|
||||
public bool IsCashPaid { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime Date { get; set; }
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; set; } = new();
|
||||
public Dictionary<int, ICarModel> PurchaseCars { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Адрес")]
|
||||
public string Address { get; set; }
|
||||
}
|
||||
}
|
@ -1,26 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class UserViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Имя пользователя")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class UserViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Имя пользователя")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class WishViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
public int PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterContracts.ViewModels
|
||||
{
|
||||
public class WishViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Description { get; set; }
|
||||
public int PresellingWorkId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface ICarBrandModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface ICarModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
int BrandId { get; }
|
||||
Dictionary<int, IEquipmentModel> CarEquipments { get; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface ICarModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
Dictionary<int, IEquipmentModel> CarEquipments { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IEquipmentModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IEquipmentModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IPresellingWorkModel: IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IPresellingWorkModel: IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int UserId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IPurchaseModel: IId
|
||||
{
|
||||
bool IsCashPaid { get; }
|
||||
int ShopId { get; }
|
||||
int UserId { get; }
|
||||
DateTime Date { get; }
|
||||
Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; }
|
||||
Dictionary<int, ICarModel> PurchaseCars { get; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IPurchaseModel: IId
|
||||
{
|
||||
bool IsCashPaid { get; }
|
||||
int UserId { get; }
|
||||
DateTime Date { get; }
|
||||
Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks { get; }
|
||||
Dictionary<int, ICarModel> PurchaseCars { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IShopModel: IId
|
||||
{
|
||||
string Address { get; }
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IWishModel: IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int PresellingWorkId { get; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDataModels.Models
|
||||
{
|
||||
public interface IWishModel: IId
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int PresellingWorkId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,9 @@ namespace AutoCenterDatabaseImplement
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<CarBrand> CarBrands { get; set; }
|
||||
public virtual DbSet<PresellingWork> PresellingWorks { get; set; }
|
||||
public virtual DbSet<Car> Cars { get; set; }
|
||||
public virtual DbSet<Purchase> Purchases { get; set; }
|
||||
public virtual DbSet<Shop> Shops{ set; get; }
|
||||
public virtual DbSet<User> Users{ set; get; }
|
||||
public virtual DbSet<Wish> Wishes { get; set; }
|
||||
public virtual DbSet<Equipment> Equipments { get; set; }
|
||||
|
@ -1,27 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoCenterContracts\AutoCenterContracts.csproj" />
|
||||
<ProjectReference Include="..\AutoCenterDataModels\AutoCenterDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoCenterContracts\AutoCenterContracts.csproj" />
|
||||
<ProjectReference Include="..\AutoCenterDataModels\AutoCenterDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,94 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDatabaseImplement.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class CarBrandStorage : ICarBrandStorage
|
||||
{
|
||||
public CarBrandViewModel? Delete(CarBrandBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var element = context.CarBrands.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.CarBrands.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CarBrandViewModel? GetElement(CarBrandSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.CarBrands.Include(x => x.Cars).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<CarBrandViewModel> GetFilteredList(CarBrandSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.CarBrands.Include(x => x.Cars).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<CarBrandViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.CarBrands.Include(x => x.Cars).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public CarBrandViewModel? Insert(CarBrandBindingModel model)
|
||||
{
|
||||
var newCarBrand = CarBrand.Create(model);
|
||||
|
||||
if (newCarBrand == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
context.CarBrands.Add(newCarBrand);
|
||||
context.SaveChanges();
|
||||
|
||||
return newCarBrand.GetViewModel;
|
||||
}
|
||||
|
||||
public CarBrandViewModel? Update(CarBrandBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var carBrand = context.CarBrands.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (carBrand == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
carBrand.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return carBrand.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -40,22 +40,21 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Brand).Include(x => x.Purchases).Include(x => x.Equipments).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Cars.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Brand).Include(x => x.Purchases).Include(x => x.Equipments).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (!model.BrandId.HasValue || x.BrandId == model.BrandId)
|
||||
return context.Cars.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Cars.Include(x => x.Purchases).Include(x => x.Equipments).Select(x => x.GetViewModel).ToList();
|
||||
return context.Cars.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
@ -86,9 +85,9 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
}
|
||||
|
||||
car.Update(model);
|
||||
if (model.CarEquipments != null)
|
||||
{
|
||||
car.UpdateEqiupment(context, model);
|
||||
if (model.CarEquipments != null)
|
||||
{
|
||||
car.UpdateEqiupment(context, model);
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
|
@ -48,8 +48,8 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Equipments.Include(x => x.Cars)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name) &&
|
||||
(!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)))
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Name) || x.Name == model.Name) &&
|
||||
(string.IsNullOrEmpty(model.Description) || x.Description == model.Description)))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
return context.PresellingWorks.Include(x => x.Wishes)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (!model.UserId.HasValue || x.UserId == model.UserId)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
|
@ -39,24 +39,23 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Purchases.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
return context.Purchases.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!model.IsCashPaid.HasValue || x.IsCashPaid == model.IsCashPaid)
|
||||
&& (!model.UserId.HasValue || x.UserId == model.UserId)
|
||||
&& (!model.Date.HasValue || x.Date == model.Date)
|
||||
&& (!model.ShopId.HasValue || x.ShopId == model.ShopId)))
|
||||
&& (!model.Date.HasValue || x.Date == model.Date)))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<PurchaseViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Purchases.Include(x => x.PresellingWorks).Include(x => x.Cars).Select(x => x.GetViewModel).ToList();
|
||||
return context.Purchases.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
||||
{
|
||||
@ -87,13 +86,13 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
}
|
||||
|
||||
purchase.Update(model);
|
||||
if (model.PurchasePresellingWorks != null)
|
||||
{
|
||||
purchase.UpdatePresellingWorks(context, model);
|
||||
if (model.PurchasePresellingWorks != null)
|
||||
{
|
||||
purchase.UpdatePresellingWorks(context, model);
|
||||
}
|
||||
if (model.PurchaseCars != null)
|
||||
{
|
||||
purchase.UpdateCars(context, model);
|
||||
if (model.PurchaseCars != null)
|
||||
{
|
||||
purchase.UpdateCars(context, model);
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterDatabaseImplement.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var element = context.Shops.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Shops.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Shops.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Shops.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Address) || x.Address == model.Address)))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
var newShop = Shop.Create(model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
context.Shops.Add(newShop);
|
||||
context.SaveChanges();
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
shop.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -37,11 +37,11 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Users.Include(x => x.Equipments).Include(x => x.Purchases).Include(x => x.PresellingWorks).FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
||||
return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Username) && !string.IsNullOrEmpty(model.Password))
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return context.Users.Include(x => x.Equipments).Include(x => x.Purchases).Include(x => x.PresellingWorks).FirstOrDefault(x => (x.Password == model.Password && x.Username == model.Username))?.GetViewModel;
|
||||
return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).FirstOrDefault(x => (x.Password == model.Password && x.Email == model.Email))?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -50,11 +50,11 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Users.Include(x => x.Equipments).Include(x => x.Purchases).Include(x => x.PresellingWorks).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Username) || x.Username == model.Username)
|
||||
&& (!string.IsNullOrEmpty(model.Password) || x.Password == model.Password)
|
||||
&& (!string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber)
|
||||
&& (!string.IsNullOrEmpty(model.Email) || x.Email == model.Email)
|
||||
return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (string.IsNullOrEmpty(model.Username) || x.Username == model.Username)
|
||||
&& (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)
|
||||
&& (string.IsNullOrEmpty(model.PhoneNumber) || x.PhoneNumber == model.PhoneNumber)
|
||||
&& (string.IsNullOrEmpty(model.Email) || x.Email == model.Email)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
@ -63,7 +63,7 @@ namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Users.Include(x => x.Equipments).Include(x => x.Purchases).Include(x => x.PresellingWorks).Select(x => x.GetViewModel).ToList();
|
||||
return context.Users.Include(x => x.Purchases).Include(x => x.PresellingWorks).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public UserViewModel? Insert(UserBindingModel model)
|
||||
|
@ -1,95 +1,95 @@
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class WishStorage : IWishStorage
|
||||
{
|
||||
public WishViewModel? Delete(WishBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var element = context.Wishes.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Wishes.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public WishViewModel? GetElement(WishSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<WishViewModel> GetFilteredList(WishSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (!string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (!string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (!model.PresellingWorkId.HasValue || x.PresellingWorkId == model.PresellingWorkId)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<WishViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public WishViewModel? Insert(WishBindingModel model)
|
||||
{
|
||||
|
||||
var newWish = Wish.Create(model);
|
||||
|
||||
if (newWish == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoCenterDatabase();
|
||||
context.Wishes.Add(newWish);
|
||||
context.SaveChanges();
|
||||
|
||||
return newWish.GetViewModel;
|
||||
}
|
||||
|
||||
public WishViewModel? Update(WishBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
var wish = context.Wishes.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (wish == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
wish.Update(model);
|
||||
context.SaveChanges();
|
||||
return wish.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.StoragesContracts;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class WishStorage : IWishStorage
|
||||
{
|
||||
public WishViewModel? Delete(WishBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
var element = context.Wishes.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Wishes.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public WishViewModel? GetElement(WishSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<WishViewModel> GetFilteredList(WishSearchModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.Where(x => ((!model.Id.HasValue || x.Id == model.Id)
|
||||
&& (string.IsNullOrEmpty(model.Name) || x.Name == model.Name)
|
||||
&& (string.IsNullOrEmpty(model.Description) || x.Description == model.Description)
|
||||
&& (!model.PresellingWorkId.HasValue || x.PresellingWorkId == model.PresellingWorkId)
|
||||
))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<WishViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
|
||||
return context.Wishes.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public WishViewModel? Insert(WishBindingModel model)
|
||||
{
|
||||
|
||||
var newWish = Wish.Create(model);
|
||||
|
||||
if (newWish == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AutoCenterDatabase();
|
||||
context.Wishes.Add(newWish);
|
||||
context.SaveChanges();
|
||||
|
||||
return newWish.GetViewModel;
|
||||
}
|
||||
|
||||
public WishViewModel? Update(WishBindingModel model)
|
||||
{
|
||||
using var context = new AutoCenterDatabase();
|
||||
var wish = context.Wishes.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (wish == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
wish.Update(model);
|
||||
context.SaveChanges();
|
||||
return wish.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,396 +1,306 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoCenterDatabase))]
|
||||
[Migration("20240503230402_Init")]
|
||||
partial class Init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BrandId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CarBrandId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarBrandId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.CarBrand", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CarBrands");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Equipments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("PresellingWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsCashPaid")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PresellingWorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresellingWorkId");
|
||||
|
||||
b.ToTable("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EquipmentsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "EquipmentsId");
|
||||
|
||||
b.HasIndex("EquipmentsId");
|
||||
|
||||
b.ToTable("CarEquipment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("CarPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.Property<int>("PresellingWorksId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PresellingWorksId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("PresellingWorkPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.CarBrand", "Brand")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("CarBrandId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Brand");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Equipments")
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", "User")
|
||||
.WithMany("PresellingWorks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", "PresellingWork")
|
||||
.WithMany("Wishes")
|
||||
.HasForeignKey("PresellingWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PresellingWork");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Equipment", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("EquipmentsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PresellingWorksId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.CarBrand", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Navigation("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Equipments");
|
||||
|
||||
b.Navigation("PresellingWorks");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoCenterDatabase))]
|
||||
[Migration("20240525230104_Init")]
|
||||
partial class Init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Equipments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("PresellingWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsCashPaid")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PresellingWorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresellingWorkId");
|
||||
|
||||
b.ToTable("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EquipmentsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "EquipmentsId");
|
||||
|
||||
b.HasIndex("EquipmentsId");
|
||||
|
||||
b.ToTable("CarEquipment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("CarPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.Property<int>("PresellingWorksId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PresellingWorksId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("PresellingWorkPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", "User")
|
||||
.WithMany("PresellingWorks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", "PresellingWork")
|
||||
.WithMany("Wishes")
|
||||
.HasForeignKey("PresellingWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PresellingWork");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Equipment", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("EquipmentsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PresellingWorksId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Navigation("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("PresellingWorks");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,322 +1,254 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarBrands",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarBrands", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Username = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
BrandId = table.Column<int>(type: "int", nullable: false),
|
||||
CarBrandId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cars", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cars_CarBrands_CarBrandId",
|
||||
column: x => x.CarBrandId,
|
||||
principalTable: "CarBrands",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Equipments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Equipments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Equipments_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresellingWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresellingWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorks_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IsCashPaid = table.Column<bool>(type: "bit", nullable: false),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarEquipment",
|
||||
columns: table => new
|
||||
{
|
||||
CarsId = table.Column<int>(type: "int", nullable: false),
|
||||
EquipmentsId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarEquipment", x => new { x.CarsId, x.EquipmentsId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CarEquipment_Cars_CarsId",
|
||||
column: x => x.CarsId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarEquipment_Equipments_EquipmentsId",
|
||||
column: x => x.EquipmentsId,
|
||||
principalTable: "Equipments",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Wishes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PresellingWorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Wishes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Wishes_PresellingWorks_PresellingWorkId",
|
||||
column: x => x.PresellingWorkId,
|
||||
principalTable: "PresellingWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarPurchase",
|
||||
columns: table => new
|
||||
{
|
||||
CarsId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchasesId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarPurchase", x => new { x.CarsId, x.PurchasesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CarPurchase_Cars_CarsId",
|
||||
column: x => x.CarsId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarPurchase_Purchases_PurchasesId",
|
||||
column: x => x.PurchasesId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresellingWorkPurchase",
|
||||
columns: table => new
|
||||
{
|
||||
PresellingWorksId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchasesId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresellingWorkPurchase", x => new { x.PresellingWorksId, x.PurchasesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorkPurchase_PresellingWorks_PresellingWorksId",
|
||||
column: x => x.PresellingWorksId,
|
||||
principalTable: "PresellingWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorkPurchase_Purchases_PurchasesId",
|
||||
column: x => x.PurchasesId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarEquipment_EquipmentsId",
|
||||
table: "CarEquipment",
|
||||
column: "EquipmentsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarPurchase_PurchasesId",
|
||||
table: "CarPurchase",
|
||||
column: "PurchasesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cars_CarBrandId",
|
||||
table: "Cars",
|
||||
column: "CarBrandId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Equipments_UserId",
|
||||
table: "Equipments",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresellingWorkPurchase_PurchasesId",
|
||||
table: "PresellingWorkPurchase",
|
||||
column: "PurchasesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresellingWorks_UserId",
|
||||
table: "PresellingWorks",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ShopId",
|
||||
table: "Purchases",
|
||||
column: "ShopId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_UserId",
|
||||
table: "Purchases",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Wishes_PresellingWorkId",
|
||||
table: "Wishes",
|
||||
column: "PresellingWorkId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarEquipment");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarPurchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresellingWorkPurchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Wishes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Equipments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cars");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresellingWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarBrands");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cars", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Equipments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Equipments", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Username = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarEquipment",
|
||||
columns: table => new
|
||||
{
|
||||
CarsId = table.Column<int>(type: "int", nullable: false),
|
||||
EquipmentsId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarEquipment", x => new { x.CarsId, x.EquipmentsId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CarEquipment_Cars_CarsId",
|
||||
column: x => x.CarsId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarEquipment_Equipments_EquipmentsId",
|
||||
column: x => x.EquipmentsId,
|
||||
principalTable: "Equipments",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresellingWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresellingWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorks_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IsCashPaid = table.Column<bool>(type: "bit", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Wishes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PresellingWorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Wishes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Wishes_PresellingWorks_PresellingWorkId",
|
||||
column: x => x.PresellingWorkId,
|
||||
principalTable: "PresellingWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarPurchase",
|
||||
columns: table => new
|
||||
{
|
||||
CarsId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchasesId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarPurchase", x => new { x.CarsId, x.PurchasesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CarPurchase_Cars_CarsId",
|
||||
column: x => x.CarsId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarPurchase_Purchases_PurchasesId",
|
||||
column: x => x.PurchasesId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresellingWorkPurchase",
|
||||
columns: table => new
|
||||
{
|
||||
PresellingWorksId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchasesId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresellingWorkPurchase", x => new { x.PresellingWorksId, x.PurchasesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorkPurchase_PresellingWorks_PresellingWorksId",
|
||||
column: x => x.PresellingWorksId,
|
||||
principalTable: "PresellingWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresellingWorkPurchase_Purchases_PurchasesId",
|
||||
column: x => x.PurchasesId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarEquipment_EquipmentsId",
|
||||
table: "CarEquipment",
|
||||
column: "EquipmentsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarPurchase_PurchasesId",
|
||||
table: "CarPurchase",
|
||||
column: "PurchasesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresellingWorkPurchase_PurchasesId",
|
||||
table: "PresellingWorkPurchase",
|
||||
column: "PurchasesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresellingWorks_UserId",
|
||||
table: "PresellingWorks",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_UserId",
|
||||
table: "Purchases",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Wishes_PresellingWorkId",
|
||||
table: "Wishes",
|
||||
column: "PresellingWorkId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarEquipment");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarPurchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresellingWorkPurchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Wishes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Equipments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cars");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresellingWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,393 +1,303 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoCenterDatabase))]
|
||||
partial class AutoCenterDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BrandId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CarBrandId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarBrandId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.CarBrand", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CarBrands");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Equipments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("PresellingWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsCashPaid")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PresellingWorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresellingWorkId");
|
||||
|
||||
b.ToTable("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EquipmentsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "EquipmentsId");
|
||||
|
||||
b.HasIndex("EquipmentsId");
|
||||
|
||||
b.ToTable("CarEquipment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("CarPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.Property<int>("PresellingWorksId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PresellingWorksId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("PresellingWorkPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.CarBrand", "Brand")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("CarBrandId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Brand");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Equipments")
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", "User")
|
||||
.WithMany("PresellingWorks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", "PresellingWork")
|
||||
.WithMany("Wishes")
|
||||
.HasForeignKey("PresellingWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PresellingWork");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Equipment", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("EquipmentsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PresellingWorksId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.CarBrand", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Navigation("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Equipments");
|
||||
|
||||
b.Navigation("PresellingWorks");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoCenterDatabase))]
|
||||
partial class AutoCenterDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Equipment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Equipments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("PresellingWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsCashPaid")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PresellingWorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresellingWorkId");
|
||||
|
||||
b.ToTable("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EquipmentsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "EquipmentsId");
|
||||
|
||||
b.HasIndex("EquipmentsId");
|
||||
|
||||
b.ToTable("CarEquipment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.Property<int>("CarsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("CarsId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("CarPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.Property<int>("PresellingWorksId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchasesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PresellingWorksId", "PurchasesId");
|
||||
|
||||
b.HasIndex("PurchasesId");
|
||||
|
||||
b.ToTable("PresellingWorkPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", "User")
|
||||
.WithMany("PresellingWorks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.User", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.Wish", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", "PresellingWork")
|
||||
.WithMany("Wishes")
|
||||
.HasForeignKey("PresellingWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PresellingWork");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarEquipment", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Equipment", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("EquipmentsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Car", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CarsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PresellingWorkPurchase", b =>
|
||||
{
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.PresellingWork", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PresellingWorksId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoCenterDatabaseImplement.Models.Purchase", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("PurchasesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.PresellingWork", b =>
|
||||
{
|
||||
b.Navigation("Wishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoCenterDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("PresellingWorks");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,24 +17,21 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int BrandId { get; set; }
|
||||
public virtual CarBrand Brand { get; set; } = new();
|
||||
public List<Equipment> Equipments { get; set; } = new();
|
||||
public List<Purchase> Purchases { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IEquipmentModel>? _equipments = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_equipments == null)
|
||||
{
|
||||
_equipments = Equipments.ToDictionary(record => record.Id, record => (record as IEquipmentModel));
|
||||
}
|
||||
return _equipments;
|
||||
}
|
||||
private Dictionary<int, IEquipmentModel>? _equipments = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IEquipmentModel> CarEquipments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_equipments == null)
|
||||
{
|
||||
_equipments = Equipments.ToDictionary(record => record.Id, record => (record as IEquipmentModel));
|
||||
}
|
||||
return _equipments;
|
||||
}
|
||||
}
|
||||
|
||||
public static Car? Create(AutoCenterDatabase context, CarBindingModel model)
|
||||
@ -48,10 +45,7 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
BrandId = model.BrandId,
|
||||
Equipments = model.CarEquipments.Select(x => new Equipment {
|
||||
Id = context.Equipments.First(y => y.Id == x.Key).Id
|
||||
}).ToList(),
|
||||
Equipments = model.CarEquipments.Select(x => context.Equipments.First(y => y.Id == x.Key)).ToList(),
|
||||
};
|
||||
}
|
||||
public void Update(CarBindingModel? model)
|
||||
@ -62,21 +56,19 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
}
|
||||
|
||||
Name = model.Name;
|
||||
BrandId = model.BrandId;
|
||||
}
|
||||
|
||||
public void UpdateEqiupment(AutoCenterDatabase context, CarBindingModel model)
|
||||
{
|
||||
Equipments.Clear();
|
||||
foreach (var id in model.CarEquipments.Keys) {
|
||||
Equipments.Add(context.Equipments.First(x => x.Id == id));
|
||||
}
|
||||
public void UpdateEqiupment(AutoCenterDatabase context, CarBindingModel model)
|
||||
{
|
||||
Equipments.Clear();
|
||||
foreach (var id in model.CarEquipments.Keys) {
|
||||
Equipments.Add(context.Equipments.First(x => x.Id == id));
|
||||
}
|
||||
}
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
BrandId = BrandId,
|
||||
CarEquipments = CarEquipments
|
||||
};
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
using Microsoft.Identity.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class CarBrand : ICarBrandModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[ForeignKey("CarBrandId")]
|
||||
public List<Car> Cars { get; set; } = new();
|
||||
|
||||
public static CarBrand? Create(CarBrandBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CarBrand()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CarBrandBindingModel? model)
|
||||
{
|
||||
if (model == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Name = model.Name;
|
||||
}
|
||||
|
||||
public CarBrandViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
}
|
@ -1,55 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Equipment: IEquipmentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public List<Car> Cars { get; set; } = new();
|
||||
|
||||
public static Equipment? Create(EquipmentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Equipment()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Description = model.Description
|
||||
};
|
||||
}
|
||||
public void Update(EquipmentBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Name = model.Name;
|
||||
Description = model.Description;
|
||||
}
|
||||
public EquipmentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Description = Description
|
||||
};
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Equipment: IEquipmentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public List<Car> Cars { get; set; } = new();
|
||||
|
||||
public static Equipment? Create(EquipmentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Equipment()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Description = model.Description
|
||||
};
|
||||
}
|
||||
public void Update(EquipmentBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Name = model.Name;
|
||||
Description = model.Description;
|
||||
}
|
||||
public EquipmentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Description = Description
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int UserId { get;private set; }
|
||||
public virtual User User { get; set; } = new();
|
||||
|
||||
|
||||
public List<Wish> Wishes { get; set; } = new();
|
||||
|
||||
public List<Purchase> Purchases { get; set; } = new();
|
||||
@ -38,7 +37,8 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Description = model.Description
|
||||
Description = model.Description,
|
||||
UserId = model.UserId
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,13 +52,15 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
Id = model.Id;
|
||||
Name = model.Name;
|
||||
Description = model.Description;
|
||||
|
||||
}
|
||||
|
||||
public PresellingWorkViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Description = Description,
|
||||
Name = Name
|
||||
Name = Name,
|
||||
UserId = UserId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,122 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Purchase : IPurchaseModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public bool IsCashPaid { get; set; }
|
||||
[Required]
|
||||
public int ShopId { get; set; }
|
||||
public virtual Shop Shop { get; set; } = new();
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public List<Car> Cars { get; set; } = new();
|
||||
private Dictionary<int, ICarModel>? _cars = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, ICarModel> PurchaseCars
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cars == null)
|
||||
{
|
||||
_cars = Cars.ToDictionary(record => record.Id, record => (record as ICarModel));
|
||||
}
|
||||
return _cars;
|
||||
}
|
||||
}
|
||||
public List<PresellingWork> PresellingWorks { get; set; } = new();
|
||||
private Dictionary<int, IPresellingWorkModel>? _presellingWorks = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_presellingWorks == null)
|
||||
{
|
||||
_presellingWorks = PresellingWorks.ToDictionary(record => record.Id, record => (record as IPresellingWorkModel));
|
||||
}
|
||||
return _presellingWorks;
|
||||
}
|
||||
}
|
||||
public static Purchase? Create(AutoCenterDatabase context, PurchaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Purchase()
|
||||
{
|
||||
Id = model.Id,
|
||||
IsCashPaid = model.IsCashPaid,
|
||||
ShopId = model.ShopId,
|
||||
UserId = model.UserId,
|
||||
Date = model.Date,
|
||||
Cars = model.PurchaseCars.Select(x => new Car
|
||||
{
|
||||
Id = context.Cars.First(y => y.Id == x.Key).Id
|
||||
}).ToList(),
|
||||
PresellingWorks = model.PurchasePresellingWorks.Select(x => new PresellingWork
|
||||
{
|
||||
Id = context.Equipments.First(y => y.Id == x.Key).Id
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PurchaseBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsCashPaid = model.IsCashPaid;
|
||||
ShopId = model.ShopId;
|
||||
UserId = model.UserId;
|
||||
Date = model.Date;
|
||||
}
|
||||
|
||||
public void UpdatePresellingWorks(AutoCenterDatabase context, PurchaseBindingModel? model)
|
||||
{
|
||||
PresellingWorks.Clear();
|
||||
foreach (var id in model.PurchasePresellingWorks.Keys)
|
||||
{
|
||||
PresellingWorks.Add(context.PresellingWorks.First(x => x.Id == id));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCars(AutoCenterDatabase context, PurchaseBindingModel? model)
|
||||
{
|
||||
Cars.Clear();
|
||||
foreach (var id in model.PurchaseCars.Keys)
|
||||
{
|
||||
Cars.Add(context.Cars.First(x => x.Id == id));
|
||||
}
|
||||
}
|
||||
|
||||
public PurchaseViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
IsCashPaid = IsCashPaid,
|
||||
ShopId = ShopId,
|
||||
UserId = UserId,
|
||||
Date = Date,
|
||||
PurchaseCars = PurchaseCars,
|
||||
PurchasePresellingWorks = PurchasePresellingWorks,
|
||||
};
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Purchase : IPurchaseModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public bool IsCashPaid { get; set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public List<Car> Cars { get; set; } = new();
|
||||
private Dictionary<int, ICarModel>? _cars = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, ICarModel> PurchaseCars
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cars == null)
|
||||
{
|
||||
_cars = Cars.ToDictionary(record => record.Id, record => (record as ICarModel));
|
||||
}
|
||||
return _cars;
|
||||
}
|
||||
}
|
||||
public List<PresellingWork> PresellingWorks { get; set; } = new();
|
||||
private Dictionary<int, IPresellingWorkModel>? _presellingWorks = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IPresellingWorkModel> PurchasePresellingWorks
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_presellingWorks == null)
|
||||
{
|
||||
_presellingWorks = PresellingWorks.ToDictionary(record => record.Id, record => (record as IPresellingWorkModel));
|
||||
}
|
||||
return _presellingWorks;
|
||||
}
|
||||
}
|
||||
public static Purchase? Create(AutoCenterDatabase context, PurchaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Purchase()
|
||||
{
|
||||
Id = model.Id,
|
||||
IsCashPaid = model.IsCashPaid,
|
||||
UserId = model.UserId,
|
||||
Date = model.Date,
|
||||
Cars = model.PurchaseCars.Select(x => context.Cars.First(y => y.Id == x.Key)).ToList(),
|
||||
PresellingWorks = model.PurchasePresellingWorks.Select(x => context.PresellingWorks.First(y => y.Id == x.Key)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PurchaseBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsCashPaid = model.IsCashPaid;
|
||||
UserId = model.UserId;
|
||||
Date = model.Date;
|
||||
}
|
||||
|
||||
public void UpdatePresellingWorks(AutoCenterDatabase context, PurchaseBindingModel? model)
|
||||
{
|
||||
PresellingWorks.Clear();
|
||||
foreach (var id in model.PurchasePresellingWorks.Keys)
|
||||
{
|
||||
PresellingWorks.Add(context.PresellingWorks.First(x => x.Id == id));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCars(AutoCenterDatabase context, PurchaseBindingModel? model)
|
||||
{
|
||||
Cars.Clear();
|
||||
foreach (var id in model.PurchaseCars.Keys)
|
||||
{
|
||||
Cars.Add(context.Cars.First(x => x.Id == id));
|
||||
}
|
||||
}
|
||||
|
||||
public PurchaseViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
IsCashPaid = IsCashPaid,
|
||||
UserId = UserId,
|
||||
Date = Date,
|
||||
PurchaseCars = PurchaseCars,
|
||||
PurchasePresellingWorks = PurchasePresellingWorks,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public virtual List<Purchase> Purchases { get; set; } = new();
|
||||
public static Shop? Create(ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
Address = model.Address
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Address = model.Address;
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Address = Address
|
||||
};
|
||||
}
|
||||
}
|
@ -1,69 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class User : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Equipment> Equipments { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Purchase> Purchases { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<PresellingWork> PresellingWorks { get; set; } = new();
|
||||
|
||||
public static User? Create(UserBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new User()
|
||||
{
|
||||
Id = model.Id,
|
||||
Username = model.Username,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public void Update(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Username = model.Username;
|
||||
Password = model.Password;
|
||||
Email = model.Email;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
public UserViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Username = Username,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
PhoneNumber = PhoneNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
|
||||
namespace AutoCenterDatabaseImplement.Models
|
||||
{
|
||||
public class User : IUserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Purchase> Purchases { get; set; } = new();
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<PresellingWork> PresellingWorks { get; set; } = new();
|
||||
|
||||
public static User? Create(UserBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new User()
|
||||
{
|
||||
Id = model.Id,
|
||||
Username = model.Username,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public void Update(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Username = model.Username;
|
||||
Password = model.Password;
|
||||
Email = model.Email;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
public UserViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Username = Username,
|
||||
Email = Email,
|
||||
Password = Password,
|
||||
PhoneNumber = PhoneNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int PresellingWorkId { get; set; }
|
||||
public virtual PresellingWork PresellingWork { get; set; } = new();
|
||||
|
||||
public static Wish? Create(WishBindingModel model)
|
||||
{
|
||||
@ -52,7 +51,8 @@ namespace AutoCenterDatabaseImplement.Models
|
||||
public WishViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Description = Description,
|
||||
Name = Name,
|
||||
Description = Description,
|
||||
PresellingWorkId = PresellingWorkId
|
||||
};
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CarBrandController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarBrandLogic _CarBrandLogic;
|
||||
public CarBrandController(ILogger<CarBrandController> logger, ICarBrandLogic CarBrandLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_CarBrandLogic = CarBrandLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CarBrandViewModel? GetCarBrand(int CarBrandId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _CarBrandLogic.ReadElement(new CarBrandSearchModel
|
||||
{
|
||||
Id = CarBrandId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения марки машины по id={Id}", CarBrandId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CarBrandViewModel>? GetCarBrandList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _CarBrandLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения марок машин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateCarBrand(CarBrandBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _CarBrandLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать марки машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateCarBrand(CarBrandBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _CarBrandLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить марку машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteCarBrand(CarBrandBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _CarBrandLogic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления марки машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -37,11 +37,11 @@ namespace AutoCenterRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CarViewModel>? GetCarList(int? carBrandId = null)
|
||||
public List<CarViewModel>? GetCarList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return !carBrandId.HasValue ? _CarLogic.ReadList(null) : _CarLogic.ReadList(new CarSearchModel { BrandId = carBrandId });
|
||||
return _CarLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -25,9 +25,9 @@ namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _PresellingWorkLogic.ReadElement(new PresellingWorkSearchModel
|
||||
{
|
||||
Id = PresellingWorkId
|
||||
return _PresellingWorkLogic.ReadElement(new PresellingWorkSearchModel
|
||||
{
|
||||
Id = PresellingWorkId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -26,8 +26,8 @@ namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
return _PurchaseLogic.ReadElement(new PurchaseSearchModel
|
||||
{
|
||||
Id = PurchaseId
|
||||
});
|
||||
Id = PurchaseId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -41,7 +41,7 @@ namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return !userId.HasValue ? _PurchaseLogic.ReadList(null) : _PurchaseLogic.ReadList(new PurchaseSearchModel { UserId = userId });
|
||||
return !userId.HasValue ? _PurchaseLogic.ReadList(null) : _PurchaseLogic.ReadList(new PurchaseSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,93 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ShopController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _ShopLogic;
|
||||
public ShopController(ILogger<ShopController> logger, IShopLogic ShopLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_ShopLogic = ShopLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModel? GetShop(int ShopId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _ShopLogic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = ShopId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина по id={Id}", ShopId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ShopViewModel>? GetShopList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _ShopLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _ShopLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать магазин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _ShopLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить магазин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _ShopLogic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,13 +21,13 @@ namespace AutoCenterRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public UserViewModel? Login(string username, string password)
|
||||
public UserViewModel? Login(string email, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _UserLogic.ReadElement(new UserSearchModel
|
||||
{
|
||||
Username = username,
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
|
@ -1,94 +1,94 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoCenterBusinessLogic.BusinessLogics;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class WishController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWishLogic _WishLogic;
|
||||
public WishController(ILogger<WishController> logger, IWishLogic Wish)
|
||||
{
|
||||
_logger = logger;
|
||||
_WishLogic = Wish;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public WishViewModel? GetWish(int WishId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.ReadElement(new WishSearchModel
|
||||
{
|
||||
Id = WishId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения пожелания по id={Id}", WishId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<WishViewModel>? GetWishList(int? presellingWorkId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !presellingWorkId.HasValue ? _WishLogic.ReadList(null) : _WishLogic.ReadList(new WishSearchModel { PresellingWorkId = presellingWorkId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка пожеланий");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать пожелание");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить пожелание");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления пожелания");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoCenterBusinessLogic.BusinessLogics;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.BusinessLogicsContracts;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class WishController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWishLogic _WishLogic;
|
||||
public WishController(ILogger<WishController> logger, IWishLogic Wish)
|
||||
{
|
||||
_logger = logger;
|
||||
_WishLogic = Wish;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public WishViewModel? GetWish(int wishId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.ReadElement(new WishSearchModel
|
||||
{
|
||||
Id = wishId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения пожелания по id={Id}", wishId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<WishViewModel>? GetWishList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка пожеланий");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать пожелание");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить пожелание");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteWish(WishBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _WishLogic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления пожелания");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,22 +11,17 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddTransient<ICarBrandStorage, CarBrandStorage>();
|
||||
builder.Services.AddTransient<ICarStorage, CarStorage>();
|
||||
builder.Services.AddTransient<IEquipmentStorage, EquipmentStorage>();
|
||||
builder.Services.AddTransient<IPresellingWorkStorage, PresellingWorkStorage>();
|
||||
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
||||
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
builder.Services.AddTransient<IWishStorage, WishStorage>();
|
||||
|
||||
|
||||
builder.Services.AddTransient<ICarBrandLogic, CarBrandLogic>();
|
||||
builder.Services.AddTransient<ICarLogic, CarLogic>();
|
||||
builder.Services.AddTransient<IEquipmentLogic, EquipmentLogic>();
|
||||
builder.Services.AddTransient<IPresellingWorkLogic, PresellingWorkLogic>();
|
||||
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
||||
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
builder.Services.AddTransient<IWishLogic, WishLogic>();
|
||||
|
||||
|
@ -1,31 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:39318",
|
||||
"sslPort": 44359
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"AutoCenterRestApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7079;http://localhost:5250",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"profiles": {
|
||||
"AutoCenterRestApi": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:7079;http://localhost:5250"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:39318",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
45
AutoCenter/AutoCenterUserApp/APIUser.cs
Normal file
45
AutoCenter/AutoCenterUserApp/APIUser.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
|
||||
namespace AutoCenterUserApp
|
||||
{
|
||||
public static class APIUser
|
||||
{
|
||||
private static readonly HttpClient _User = new();
|
||||
public static UserViewModel? User { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_User.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_User.DefaultRequestHeaders.Accept.Clear();
|
||||
_User.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _User.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 requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8,
|
||||
"application/json");
|
||||
var response = _User.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
18
AutoCenter/AutoCenterUserApp/AutoCenterUserApp.csproj
Normal file
18
AutoCenter/AutoCenterUserApp/AutoCenterUserApp.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MailKit" Version="4.6.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoCenterContracts\AutoCenterContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
644
AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs
Normal file
644
AutoCenter/AutoCenterUserApp/Controllers/HomeController.cs
Normal file
@ -0,0 +1,644 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using AutoCenterContracts.BindingModels;
|
||||
using AutoCenterContracts.SearchModels;
|
||||
using AutoCenterContracts.ViewModels;
|
||||
using AutoCenterDataModels.Models;
|
||||
using AutoCenterUserApp.Models;
|
||||
|
||||
namespace AutoCenterUserApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.User);
|
||||
}
|
||||
[HttpPost]
|
||||
public void Privacy(string email, string password, string username, string phoneNumber)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(email) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(phoneNumber))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль, имя пользователя и номер телефона");
|
||||
}
|
||||
APIUser.PostRequest("api/user/updatedata", new UserBindingModel
|
||||
{
|
||||
Id = APIUser.User.Id,
|
||||
Username = username,
|
||||
Email = email,
|
||||
Password = password,
|
||||
PhoneNumber = phoneNumber
|
||||
});
|
||||
APIUser.User.Username = username;
|
||||
APIUser.User.Email = email;
|
||||
APIUser.User.Password = password;
|
||||
APIUser.User.PhoneNumber = phoneNumber;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string email, string password, string username, string phoneNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(phoneNumber))
|
||||
{
|
||||
throw new Exception("Введите почту, пароль, имя пользователя и номер телефона");
|
||||
}
|
||||
APIUser.PostRequest("api/user/register", new UserBindingModel
|
||||
{
|
||||
Username = username,
|
||||
Email = email,
|
||||
Password = password,
|
||||
PhoneNumber = phoneNumber
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string email, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите email и пароль");
|
||||
}
|
||||
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?email={email}&password={password}");
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
// Purchases
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult CreatePurchase()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreatePurchase(bool isCashPaid, DateTime date, List<int> cars, List<int> presellingWorks)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/purchase/createpurchase", new PurchaseBindingModel
|
||||
{
|
||||
IsCashPaid = isCashPaid,
|
||||
Date = date,
|
||||
PurchaseCars = cars.ToDictionary(record => record, record => new CarSearchModel { Id = record } as ICarModel),
|
||||
PurchasePresellingWorks = presellingWorks.ToDictionary(record => record, record => new PresellingWorkSearchModel { Id = record } as IPresellingWorkModel),
|
||||
UserId = APIUser.User.Id
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult DeletePurchase()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeletePurchase(int purchaseId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/purchase/deletepurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = purchaseId
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
public IActionResult UpdatePurchase()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Purchases = APIUser.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchaselist?userid={APIUser.User.Id}");
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<CarViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdatePurchase(int purchaseId, bool isCashPaid, DateTime date, List<int> cars, List<int> presellingWorks)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/purchase/updatepurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = purchaseId,
|
||||
IsCashPaid = isCashPaid,
|
||||
Date = date,
|
||||
PurchaseCars = cars.ToDictionary(record => record, record => new CarSearchModel { Id = record } as ICarModel),
|
||||
PurchasePresellingWorks = presellingWorks.ToDictionary(record => record, record => new PresellingWorkSearchModel { Id = record } as IPresellingWorkModel),
|
||||
UserId = APIUser.User.Id
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<PurchaseViewModel, List<string>>? GetPurchase(int purhcaseId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<Tuple<PurchaseViewModel, List<string>>>($"api/purchase/getpurchase?purhcaseid={purhcaseId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Wishes
|
||||
public IActionResult Wish()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<WishViewModel>>($"api/wish/getwishlist"));
|
||||
}
|
||||
|
||||
public IActionResult CreateWish()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateWish(string name, string description, int presellingWorkId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/wish/createwish", new WishBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Description = description,
|
||||
PresellingWorkId = presellingWorkId
|
||||
});
|
||||
Response.Redirect("Wish");
|
||||
}
|
||||
public IActionResult DeleteWish()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Wishes = APIUser.GetRequest<List<WishViewModel>>($"api/wish/getwishlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteWish(int wishId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/wish/deletewish", new WishBindingModel
|
||||
{
|
||||
Id = wishId
|
||||
});
|
||||
Response.Redirect("Wish");
|
||||
}
|
||||
|
||||
public IActionResult UpdateWish()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Wishes = APIUser.GetRequest<List<WishViewModel>>($"api/wish/getwishlist");
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateWish(int wishId, string name, string description, int presellingWorkId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/wish/updatewish", new WishBindingModel
|
||||
{
|
||||
Id = wishId,
|
||||
Name = name,
|
||||
Description = description,
|
||||
PresellingWorkId = presellingWorkId
|
||||
});
|
||||
Response.Redirect("Wish");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<WishViewModel, List<string>>? GetWish(int wishId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<Tuple<WishViewModel, List<string>>>($"api/wish/getwish?wishid={wishId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// PresellingWorks
|
||||
public IActionResult PresellingWork()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult CreatePresellingWork()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreatePresellingWork(string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
|
||||
APIUser.PostRequest("api/presellingwork/createpresellingwork", new PresellingWorkBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Description = description,
|
||||
UserId = APIUser.User.Id
|
||||
});
|
||||
Response.Redirect("PresellingWork");
|
||||
}
|
||||
public IActionResult DeletePresellingWork()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult UpdatePresellingWork()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.PresellingWorks = APIUser.GetRequest<List<PresellingWorkViewModel>>($"api/presellingwork/getpresellingworklist?userid={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeletePresellingWork(int presellingWorkId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/presellingwork/deletepresellingwork", new PresellingWorkBindingModel
|
||||
{
|
||||
Id = presellingWorkId
|
||||
});
|
||||
Response.Redirect("PresellingWork");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdatePresellingWork(int presellingWorkId, string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/presellingWork/updatepresellingwork", new PresellingWorkBindingModel
|
||||
{
|
||||
Id = presellingWorkId,
|
||||
Name = name,
|
||||
Description = description,
|
||||
UserId = APIUser.User.Id
|
||||
});
|
||||
Response.Redirect("PresellingWork");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PresellingWorkViewModel? GetPresellingWork(int presellingworkId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<PresellingWorkViewModel>($"api/presellingwork/getpresellingwork?presellingworkid={presellingworkId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// Cars
|
||||
public IActionResult Car()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist"));
|
||||
}
|
||||
|
||||
public IActionResult CreateCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCar(string name, List<int> equipments)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
|
||||
APIUser.PostRequest("api/car/createcar", new CarBindingModel
|
||||
{
|
||||
Name = name,
|
||||
CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel)
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
public IActionResult DeleteCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
return View();
|
||||
}
|
||||
public IActionResult UpdateCar()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Cars = APIUser.GetRequest<List<CarViewModel>>($"api/car/getcarlist");
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteCar(int carId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/car/deletecar", new CarBindingModel
|
||||
{
|
||||
Id = carId
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCar(int carId, string name, List<int> equipments)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/car/updatecar", new CarBindingModel
|
||||
{
|
||||
Id = carId,
|
||||
Name = name,
|
||||
CarEquipments = equipments.ToDictionary(record => record, record => new EquipmentSearchModel { Id = record } as IEquipmentModel)
|
||||
});
|
||||
Response.Redirect("Car");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PresellingWorkViewModel? GetCar(int carId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<PresellingWorkViewModel>($"api/car/getcar?carid={carId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// Equipments
|
||||
public IActionResult Equipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist"));
|
||||
}
|
||||
|
||||
public IActionResult CreateEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateEquipment(string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
|
||||
APIUser.PostRequest("api/equipment/createequipment", new EquipmentBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
public IActionResult DeleteEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
public IActionResult UpdateEquipment()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Equipments = APIUser.GetRequest<List<EquipmentViewModel>>($"api/equipment/getequipmentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteEquipment(int equipmentId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIUser.PostRequest("api/equipment/deleteequipment", new EquipmentBindingModel
|
||||
{
|
||||
Id = equipmentId
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateEquipment(int equipmentId, string name, string description)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
APIUser.PostRequest("api/equipment/updateequipment", new EquipmentBindingModel
|
||||
{
|
||||
Id = equipmentId,
|
||||
Name = name,
|
||||
Description = description
|
||||
});
|
||||
Response.Redirect("Equipment");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public EquipmentViewModel? GetEquipment(int equipmentId)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIUser.GetRequest<EquipmentViewModel>($"api/equipment/getequipment?equipmentid={equipmentId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
9
AutoCenter/AutoCenterUserApp/Models/ErrorViewModel.cs
Normal file
9
AutoCenter/AutoCenterUserApp/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace AutoCenterUserApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
30
AutoCenter/AutoCenterUserApp/Program.cs
Normal file
30
AutoCenter/AutoCenterUserApp/Program.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using AutoCenterUserApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
APIUser.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();
|
28
AutoCenter/AutoCenterUserApp/Properties/launchSettings.json
Normal file
28
AutoCenter/AutoCenterUserApp/Properties/launchSettings.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"profiles": {
|
||||
"AutoCenterUserApp": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:7228;http://localhost:5185"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
},
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:18890",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
39
AutoCenter/AutoCenterUserApp/Views/Home/Car.cshtml
Normal file
39
AutoCenter/AutoCenterUserApp/Views/Home/Car.cshtml
Normal file
@ -0,0 +1,39 @@
|
||||
@using AutoCenterContracts.ViewModels
|
||||
@model List<CarViewModel>
|
||||
@{
|
||||
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="CreateCar">Создать машину</a>
|
||||
<a asp-action="UpdateCar">Обновить машину</a>
|
||||
<a asp-action="DeleteCar">Удалить машину</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.Name)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
27
AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml
Normal file
27
AutoCenter/AutoCenterUserApp/Views/Home/CreateCar.cshtml
Normal file
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateСфк";
|
||||
}
|
||||
|
||||
<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" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Комплектации:</div>
|
||||
<div class="col-8">
|
||||
<select name="equipments" class="form-control" multiple size="5" id="equipments" asp-items="@(new SelectList(@ViewBag.Equipments,"Id", "Name" ))" required></select>
|
||||
</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>
|
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateEqipment";
|
||||
}
|
||||
|
||||
<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" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="description" id="description" required />
|
||||
</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>
|
@ -0,0 +1,27 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreatePresellingWork";
|
||||
}
|
||||
|
||||
<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" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="description" id="description" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" required />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,39 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreatePurchase";
|
||||
}
|
||||
|
||||
<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="checkbox" name="isCashPaid" id="isCashPaid" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" name="date" id="date" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Машины:</div>
|
||||
<div class="col-8">
|
||||
<select name="cars" class="form-control" multiple size="5" id="cars" asp-items="@(new SelectList(@ViewBag.Cars,"Id", "Name" ))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Предпродажные работы:</div>
|
||||
<div class="col-8">
|
||||
<select name="presellingWorks" class="form-control" multiple size="5" id="presellingWorks" asp-items="@(new SelectList(@ViewBag.PresellingWorks,"Id", "Name" ))" required></select>
|
||||
</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>
|
33
AutoCenter/AutoCenterUserApp/Views/Home/CreateWish.cshtml
Normal file
33
AutoCenter/AutoCenterUserApp/Views/Home/CreateWish.cshtml
Normal file
@ -0,0 +1,33 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateWish";
|
||||
}
|
||||
|
||||
<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" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="description" id="description" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Предпродажная работа:</div>
|
||||
<div class="col-8">
|
||||
<select id="presellingWorkId" name="presellingWorkId" class="form-control" asp-items="@(new SelectList(@ViewBag.PresellingWorks,"Id", "Name" ))" required></select>
|
||||
</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>
|
18
AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml
Normal file
18
AutoCenter/AutoCenterUserApp/Views/Home/DeleteCar.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteCar";
|
||||
}
|
||||
<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 id="car" name="carId" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteEquipment";
|
||||
}
|
||||
<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 id="equipment" name="equipmentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Equipments, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeletePresellingWork";
|
||||
}
|
||||
<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 id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@(new SelectList(@ViewBag.PresellingWorks, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeletePurchase";
|
||||
}
|
||||
<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 id="purchase" name="purchaseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id", "Date"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
18
AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml
Normal file
18
AutoCenter/AutoCenterUserApp/Views/Home/DeleteWish.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteWish";
|
||||
}
|
||||
<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 id="wish" name="wishId" class="form-control" asp-items="@(new SelectList(@ViewBag.Wishes, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
20
AutoCenter/AutoCenterUserApp/Views/Home/Enter.cshtml
Normal file
20
AutoCenter/AutoCenterUserApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,20 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
<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="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>
|
41
AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml
Normal file
41
AutoCenter/AutoCenterUserApp/Views/Home/Equipment.cshtml
Normal file
@ -0,0 +1,41 @@
|
||||
@using AutoCenterContracts.ViewModels
|
||||
@model List<EquipmentViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Equipment";
|
||||
}
|
||||
<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="CreateEquipment">Создать Комплектацию</a>
|
||||
<a asp-action="UpdateEquipment">Обновить Комплектацию</a>
|
||||
<a asp-action="DeleteEquipment">Удалить Комплектацию</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.Name)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Description)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
43
AutoCenter/AutoCenterUserApp/Views/Home/Index.cshtml
Normal file
43
AutoCenter/AutoCenterUserApp/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,43 @@
|
||||
@using AutoCenterContracts.ViewModels
|
||||
@model List<PurchaseViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Purchase";
|
||||
}
|
||||
<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="CreatePurchase">Создать покупку</a>
|
||||
<a asp-action="UpdatePurchase">Обновить покупку</a>
|
||||
<a asp-action="DeletePurchase">Удалить покупку</a>
|
||||
<a asp-action="PurchaseCar">Связать покупку и машину</a>
|
||||
<a asp-action="PurchasePresellingWork">Связать покупку и предпродажную работу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.IsCashPaid)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Date.Date)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -0,0 +1,42 @@
|
||||
@using AutoCenterContracts.ViewModels
|
||||
@model List<PresellingWorkViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "PresellingWork";
|
||||
}
|
||||
<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="CreatePresellingWork">Создать предпродажную работу</a>
|
||||
<a asp-action="UpdatePresellingWork">Обновить предпродажную работу</a>
|
||||
<a asp-action="DeletePresellingWork">Удалить предпродажную работу</a>
|
||||
<a asp-action="PresellingWorkWish">Связать пожелание и предродажюную работу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.Name)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Description)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
32
AutoCenter/AutoCenterUserApp/Views/Home/Privacy.cshtml
Normal file
32
AutoCenter/AutoCenterUserApp/Views/Home/Privacy.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@using AutoCenterContracts.ViewModels
|
||||
|
||||
@model UserViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<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="email" value="@Model.Email" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<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="username" value="@Model.Username" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8"><input type="text" name="phoneNumber" value="@Model.PhoneNumber" /></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>
|
67
AutoCenter/AutoCenterUserApp/Views/Home/PurchaseCar.cshtml
Normal file
67
AutoCenter/AutoCenterUserApp/Views/Home/PurchaseCar.cshtml
Normal file
@ -0,0 +1,67 @@
|
||||
@using AutoCenterContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "StudentEducationPlans";
|
||||
}
|
||||
|
||||
<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 id="student" name="studentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Students, "Id", "StudentFIO"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="text" name="fio" id="fio" class="visually-hidden" />
|
||||
<input type="text" name="email" id="email" class="visually-hidden" />
|
||||
<input type="text" name="phoneNumber" id="phoneNumber" class="visually-hidden" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Планы обучения:</div>
|
||||
<div class="col-8">
|
||||
<select name="educationPlans" class="form-control" multiple size="5" id="educationPlans">
|
||||
@foreach (var plan in ViewBag.EducationPlans)
|
||||
{
|
||||
<option value="@plan.Id" data-name="@plan.EducationPlanName">@plan.EducationPlanName</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var student = $('#student').val();
|
||||
if (student) {
|
||||
$("#educationPlans option:selected").removeAttr("selected");
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetStudent",
|
||||
data: { studentId: student },
|
||||
success: function (result) {
|
||||
$('#fio').val(result.item1.studentFIO);
|
||||
$('#email').val(result.item1.email);
|
||||
$('#phoneNumber').val(result.item1.phoneNumber);
|
||||
$.map(result.item2, function (n) {
|
||||
$(`option[data-name="${n}"]`).attr("selected", "selected");
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#student').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
@using AutoCenterContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "StudentEducationPlans";
|
||||
}
|
||||
|
||||
<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 id="student" name="studentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Students, "Id", "StudentFIO"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="text" name="fio" id="fio" class="visually-hidden" />
|
||||
<input type="text" name="email" id="email" class="visually-hidden" />
|
||||
<input type="text" name="phoneNumber" id="phoneNumber" class="visually-hidden" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Планы обучения:</div>
|
||||
<div class="col-8">
|
||||
<select name="educationPlans" class="form-control" multiple size="5" id="educationPlans">
|
||||
@foreach (var plan in ViewBag.EducationPlans)
|
||||
{
|
||||
<option value="@plan.Id" data-name="@plan.EducationPlanName">@plan.EducationPlanName</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var student = $('#student').val();
|
||||
if (student) {
|
||||
$("#educationPlans option:selected").removeAttr("selected");
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetStudent",
|
||||
data: { studentId: student },
|
||||
success: function (result) {
|
||||
$('#fio').val(result.item1.studentFIO);
|
||||
$('#email').val(result.item1.email);
|
||||
$('#phoneNumber').val(result.item1.phoneNumber);
|
||||
$.map(result.item2, function (n) {
|
||||
$(`option[data-name="${n}"]`).attr("selected", "selected");
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#student').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
32
AutoCenter/AutoCenterUserApp/Views/Home/Register.cshtml
Normal file
32
AutoCenter/AutoCenterUserApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@{
|
||||
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="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-4">Имя пользователя:</div>
|
||||
<div class="col-8"><input type="text" name="username" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Телефон:</div>
|
||||
<div class="col-8"><input type="text" name="phoneNumber" placeholder="+79370350065" minlength="12" maxlength="12" /></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>
|
67
AutoCenter/AutoCenterUserApp/Views/Home/UpdateCar.cshtml
Normal file
67
AutoCenter/AutoCenterUserApp/Views/Home/UpdateCar.cshtml
Normal file
@ -0,0 +1,67 @@
|
||||
@using AutoCenterContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateCar";
|
||||
}
|
||||
|
||||
<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 id="car" name="carId" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars, "Id", "Name"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Комплектации:</div>
|
||||
<div class="col-8">
|
||||
<select name="equipments" class="form-control" multiple size="5" id="equipments" required>
|
||||
@foreach (var item in ViewBag.Equipments)
|
||||
{
|
||||
<option value="@item.Id" data-name="@item.Name">@item.Name</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var car = $('#car').val();
|
||||
if (car) {
|
||||
$("#cars option:selected").removeAttr("selected");
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetCar",
|
||||
data: { studentId: car },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.name);
|
||||
$('#description').val(result.item1.description);
|
||||
$.map(result.item2, function (n) {
|
||||
$(`option[data-name="${n}"]`).attr("selected", "selected");
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#car').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
@using AutoCenterContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateEquipment";
|
||||
}
|
||||
|
||||
<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 id="equipmentId" name="equipmentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Equipments, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="description" id="description" required />
|
||||
</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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var equipment = $('equipmentId').val();
|
||||
if (equipment) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetEquipment",
|
||||
data: { equipmentId : equipment },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.name);
|
||||
$('#description').val(result.item1.description);
|
||||
$.map(result.item2, function (n) {
|
||||
$(`option[data-name="${n}"]`).attr("selected", "selected");
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#equipmentId').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
@using AutoCenterContracts.ViewModels;
|
||||
@{
|
||||
ViewData["Title"] = "UpdatePresellingWork";
|
||||
}
|
||||
|
||||
<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 id="presellingWork" name="presellingWorkId" class="form-control" asp-items="@(new SelectList(@ViewBag.PresellingWorks, "Id", "Name"))" required></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="description" id="description" required />
|
||||
</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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var presellingWork = $('#presellignWork').val();
|
||||
if (presellingWork) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetPresellignWork",
|
||||
data: { presellingWorkId: presellingWork },
|
||||
success: function (result) {
|
||||
$('#name').val(result.name);
|
||||
$('#description').val(result.description);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#presellingWork').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user