Compare commits
55 Commits
19d3158342
...
BACKDEV-41
| Author | SHA1 | Date | |
|---|---|---|---|
| ddf2ad1002 | |||
| 0837497835 | |||
| 0b911e13f9 | |||
| bbf04c8cc0 | |||
| bcd8b8f156 | |||
| 0721ac8f89 | |||
| 6838c3f610 | |||
| 8ad556c01f | |||
| b558c09229 | |||
| 9f0048fd59 | |||
| b8753069d7 | |||
|
|
5a3392e800 | ||
|
|
dadaf9c744 | ||
|
|
311b70d3be | ||
|
|
0cf11372a7 | ||
|
|
0ac9228a41 | ||
|
|
79fcf7e9a9 | ||
|
|
63e1480d3d | ||
|
|
3d8f25f4b0 | ||
| d04752b2ba | |||
| c229b58d9d | |||
| 80f5b2fde7 | |||
|
|
6ca4695641 | ||
|
|
de8a64c509 | ||
|
|
c2c4759c68 | ||
|
|
7f6c134c57 | ||
| fa4c708e1c | |||
|
|
fa4bf3e8d4 | ||
|
|
2ff2aeb812 | ||
|
|
765b68f754 | ||
|
|
2f7003d3b7 | ||
|
|
0a6730a722 | ||
|
|
7bcfa7e0e0 | ||
| 060c5dc37f | |||
|
|
3e68f069ce | ||
|
|
9df5c5d358 | ||
|
|
0fd8a7fd8f | ||
| ca6035d7a1 | |||
|
|
ed846686ce | ||
|
|
7f429638b5 | ||
| 4733811487 | |||
| 9688e5eb1c | |||
| 34ada3ab98 | |||
|
|
95b2759a12 | ||
|
|
070473b0d6 | ||
|
|
affb89bb59 | ||
|
|
56b6290c71 | ||
|
|
96c186a590 | ||
|
|
326b2b2b87 | ||
|
|
09dcc021c8 | ||
| e249402043 | |||
|
|
1ae74a6fdb | ||
|
|
5337beeb65 | ||
|
|
db1fdee078 | ||
| 4719cf6c0f |
@@ -11,7 +11,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreContra
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreBusinessLogic", "ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj", "{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDatabaseImplement", "ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj", "{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDatabaseImplement", "ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj", "{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreREST", "ComputerHardwareStoreREST\ComputerHardwareStoreREST.csproj", "{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VendorClient", "VendorClient\VendorClient.csproj", "{BD0D9FB9-7F73-4011-AAC8-D5508EC5EB53}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StoreKeeperClient", "StoreKeeperClient\StoreKeeperClient.csproj", "{E31BB0DA-6493-4260-9EE7-6C330E12D2F1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -35,10 +41,22 @@ Global
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{20E4D287-C0F4-4DAB-B338-349F8B6EA22B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD0D9FB9-7F73-4011-AAC8-D5508EC5EB53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD0D9FB9-7F73-4011-AAC8-D5508EC5EB53}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD0D9FB9-7F73-4011-AAC8-D5508EC5EB53}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD0D9FB9-7F73-4011-AAC8-D5508EC5EB53}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E31BB0DA-6493-4260-9EE7-6C330E12D2F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E31BB0DA-6493-4260-9EE7-6C330E12D2F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E31BB0DA-6493-4260-9EE7-6C330E12D2F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E31BB0DA-6493-4260-9EE7-6C330E12D2F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
|
||||
public List<CommentViewModel>? ReadList(CommentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList Comment. Date:{Date}. Id:{Id}", model?.Date, model?.Id);
|
||||
_logger.LogInformation("ReadList Comment. Id:{Id}", model?.Id);
|
||||
var list = model == null ? _commentStorage.GetFullList() :
|
||||
_commentStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
@@ -38,7 +38,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement Comment. Date:{Date}. Id:{ Id}", model.Date, model.Id);
|
||||
_logger.LogInformation("ReadElement Comment. Id:{ Id}", model.Id);
|
||||
var element = _commentStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
@@ -92,9 +92,9 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Date))
|
||||
if (string.IsNullOrEmpty(model.Text))
|
||||
{
|
||||
throw new ArgumentNullException("Нет даты у комментария", nameof(model.Date));
|
||||
throw new ArgumentNullException("Нет текста комментария", nameof(model.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException(nameof(element));
|
||||
}
|
||||
|
||||
model.OrderProduct = element.OrderProduct;
|
||||
model.OrderProducts = element.OrderProducts;
|
||||
model.DateCreate = element.DateCreate;
|
||||
model.Status = element.Status;
|
||||
|
||||
|
||||
@@ -92,10 +92,6 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.DateCreate == null) // TODO чего блин, всмысле нет
|
||||
{
|
||||
throw new ArgumentNullException("Нет даты создания покупки", nameof(model.Date));
|
||||
}
|
||||
if (model.Cost <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость покупки должна быть больше 0", nameof(model.Cost));
|
||||
|
||||
@@ -7,12 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="BusinessLogic\**" />
|
||||
<EmbeddedResource Remove="BusinessLogic\**" />
|
||||
<None Remove="BusinessLogic\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcel
|
||||
{
|
||||
public void CreateReportProduct(ExcelInfo info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
uint rowIndex = 2;
|
||||
foreach (var pb in info.ProductBuilds)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pb.ProductName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var Build in pb.Builds)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = Build.Item1,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = Build.Item2.ToString(),
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
public void CreateReportBuild(ExcelInfo info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
uint rowIndex = 2;
|
||||
foreach (var bp in info.BuildProducts)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = bp.BuildName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var Product in bp.Products)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = Product.Item1,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = Product.Item2.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
protected abstract void SaveExcel(ExcelInfo info);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWord
|
||||
{
|
||||
public void CreateProductBuildReport(WordInfo info)
|
||||
{
|
||||
CreateWord(info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
List<WordRow> rows = new List<WordRow>();
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)> {
|
||||
("Сборки", new WordTextProperties { Size = "24", Bold = true }),
|
||||
("Товары", new WordTextProperties { Size = "24", Bold = true }),
|
||||
("Стоимость", new WordTextProperties { Size = "24", Bold = true })
|
||||
}
|
||||
});
|
||||
|
||||
var reportRecords = info.ProductBuilds;
|
||||
foreach (var reportRecord in reportRecords)
|
||||
{
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)>
|
||||
{
|
||||
(reportRecord.ProductName, new WordTextProperties { Size = "24" }),
|
||||
("", new WordTextProperties { }),
|
||||
("", new WordTextProperties { })
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < reportRecord.Builds.Count; i++)
|
||||
{
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)>
|
||||
{
|
||||
("", new WordTextProperties { }),
|
||||
(reportRecord.Builds[i].Build, new WordTextProperties { Size = "24" }),
|
||||
(reportRecord.Builds[i].Price.ToString(), new WordTextProperties { Size = "24" })
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CreateTable(rows);
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
public void CreateBuildProductReport(WordInfo info)
|
||||
{
|
||||
CreateWord(info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
List<WordRow> rows = new List<WordRow>();
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)> {
|
||||
("Товары", new WordTextProperties { Size = "24", Bold = true }),
|
||||
("Сборки", new WordTextProperties { Size = "24", Bold = true }),
|
||||
("Стоимость", new WordTextProperties { Size = "24", Bold = true })
|
||||
}
|
||||
});
|
||||
|
||||
var reportRecords = info.BuildProducts;
|
||||
foreach (var reportRecord in reportRecords)
|
||||
{
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)>
|
||||
{
|
||||
(reportRecord.BuildName, new WordTextProperties { Size = "24" }),
|
||||
("", new WordTextProperties { }),
|
||||
("", new WordTextProperties { })
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < reportRecord.Products.Count; i++)
|
||||
{
|
||||
rows.Add(new WordRow
|
||||
{
|
||||
Rows = new List<(string, WordTextProperties)>
|
||||
{
|
||||
("", new WordTextProperties { }),
|
||||
(reportRecord.Products[i].Product, new WordTextProperties { Size = "24" }),
|
||||
(reportRecord.Products[i].Price.ToString(), new WordTextProperties { Size = "24" })
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CreateTable(rows);
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
protected abstract void CreateWord(WordInfo info);
|
||||
|
||||
protected abstract void CreateTable(List<WordRow> rows);
|
||||
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public string ColumnName { get; set; } = string.Empty;
|
||||
public uint RowIndex { get; set; }
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportBuildProductViewModel> BuildProducts { get; set; } = new();
|
||||
public List<ReportProductBuildViewModel> ProductBuilds {get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; } = string.Empty;
|
||||
public string CellToName { get; set; } = string.Empty;
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportBuildProductViewModel> BuildProducts { get; set; } = new();
|
||||
public List<ReportProductBuildViewModel> ProductBuilds { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordRow
|
||||
{
|
||||
public List<(string, WordTextProperties)> Rows { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
public bool Bold { get; set; }
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcel : AbstractSaveToExcel
|
||||
{
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
private static void CreateStyles(WorkbookPart workbookpart)
|
||||
{
|
||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var fontUsual = new Font();
|
||||
fontUsual.Append(new FontSize() { Val = 12D });
|
||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Theme = 1U });
|
||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var fontTitle = new Font();
|
||||
fontTitle.Append(new Bold());
|
||||
fontTitle.Append(new FontSize() { Val = 14D });
|
||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Theme = 1U });
|
||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTitle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill()
|
||||
{
|
||||
PatternType = PatternValues.Gray125
|
||||
});
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
borderNoBorder.Append(new RightBorder());
|
||||
borderNoBorder.Append(new TopBorder());
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
var borderThin = new Border();
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Indexed = 64U });
|
||||
var rightBorder = new RightBorder()
|
||||
{
|
||||
Style = BorderStyleValues.Thin
|
||||
};
|
||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Indexed = 64U });
|
||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Indexed = 64U });
|
||||
var bottomBorder = new BottomBorder()
|
||||
{
|
||||
Style = BorderStyleValues.Thin
|
||||
};
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
||||
{ Indexed = 64U });
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
borderThin.Append(bottomBorder);
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||
var cellFormatStyle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U
|
||||
};
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
var cellFormats = new CellFormats() { Count = 3U };
|
||||
var cellFormatFont = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true
|
||||
};
|
||||
var cellFormatFontAndBorder = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 0U,
|
||||
FillId = 0U,
|
||||
BorderId = 1U,
|
||||
FormatId = 0U,
|
||||
ApplyFont = true,
|
||||
ApplyBorder = true
|
||||
};
|
||||
var cellFormatTitle = new CellFormat()
|
||||
{
|
||||
NumberFormatId = 0U,
|
||||
FontId = 1U,
|
||||
FillId = 0U,
|
||||
BorderId = 0U,
|
||||
FormatId = 0U,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true,
|
||||
Horizontal = HorizontalAlignmentValues.Center
|
||||
},
|
||||
ApplyFont = true
|
||||
};
|
||||
cellFormats.Append(cellFormatFont);
|
||||
cellFormats.Append(cellFormatFontAndBorder);
|
||||
cellFormats.Append(cellFormatTitle);
|
||||
var cellStyles = new CellStyles() { Count = 1U };
|
||||
cellStyles.Append(new CellStyle()
|
||||
{
|
||||
Name = "Normal",
|
||||
FormatId = 0U,
|
||||
BuiltinId = 0U
|
||||
});
|
||||
|
||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
||||
{ Count = 0U };
|
||||
|
||||
var tableStyles = new TableStyles()
|
||||
{
|
||||
Count = 0U,
|
||||
DefaultTableStyle = "TableStyleMedium2",
|
||||
DefaultPivotStyle = "PivotStyleLight16"
|
||||
};
|
||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||
var stylesheetExtension1 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
||||
});
|
||||
var stylesheetExtension2 = new StylesheetExtension()
|
||||
{
|
||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
||||
};
|
||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
stylesheetExtension2.Append(new TimelineStyles()
|
||||
{
|
||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
||||
});
|
||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||
sp.Stylesheet.Append(fonts);
|
||||
sp.Stylesheet.Append(fills);
|
||||
sp.Stylesheet.Append(borders);
|
||||
sp.Stylesheet.Append(cellStyleFormats);
|
||||
sp.Stylesheet.Append(cellFormats);
|
||||
sp.Stylesheet.Append(cellStyles);
|
||||
sp.Stylesheet.Append(differentialFormats);
|
||||
sp.Stylesheet.Append(tableStyles);
|
||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение номера стиля из типа
|
||||
/// </summary>
|
||||
/// <param name="styleInfo"></param>
|
||||
/// <returns></returns>
|
||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||
{
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
// Создаем книгу (в ней хранятся листы)
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
CreateStyles(workbookpart);
|
||||
// Получаем/создаем хранилище текстов для книги
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||
?
|
||||
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||
:
|
||||
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
// Создаем SharedStringTable, если его нет
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
// Создаем лист в книгу
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
// Добавляем лист в книгу
|
||||
var sheets =
|
||||
_spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
_worksheet = worksheetPart.Worksheet;
|
||||
}
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
if (sheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Ищем строку, либо добавляем ее
|
||||
Row row;
|
||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||
{
|
||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||
sheetData.Append(row);
|
||||
}
|
||||
// Ищем нужную ячейку
|
||||
Cell cell;
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Все ячейки должны быть последовательно друг за другом расположены
|
||||
// нужно определить, после какой вставлять
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var newCell = new Cell()
|
||||
{
|
||||
CellReference =
|
||||
excelParams.CellReference
|
||||
};
|
||||
row.InsertBefore(newCell, refCell);
|
||||
cell = newCell;
|
||||
}
|
||||
// вставляем новый текст
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||
}
|
||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells mergeCells;
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells,
|
||||
_worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells,
|
||||
_worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
var mergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(excelParams.Merge)
|
||||
};
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
protected override void SaveExcel(ExcelInfo info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace ComputerHardwareStoreBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWord : AbstractSaveToWord
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
|
||||
private Body? _docBody;
|
||||
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
|
||||
var pageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
|
||||
properties.AppendChild(pageSize);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var properties = new ParagraphProperties();
|
||||
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
properties.AppendChild(new Indentation());
|
||||
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||
}
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected override void CreateWord(WordInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<WordRow> data)
|
||||
{
|
||||
if (_docBody == null || data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Table table = new Table();
|
||||
var tableProp = new TableProperties();
|
||||
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||
tableProp.AppendChild(new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||
));
|
||||
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||
table.AppendChild(tableProp);
|
||||
TableGrid tableGrid = new TableGrid();
|
||||
for (int j = 0; j < data[0].Rows.Count; ++j)
|
||||
{
|
||||
tableGrid.AppendChild(new GridColumn() { Width = "1600" });
|
||||
}
|
||||
table.AppendChild(tableGrid);
|
||||
for (int i = 0; i < data.Count; ++i)
|
||||
{
|
||||
TableRow docRow = new TableRow();
|
||||
for (int j = 0; j < data[i].Rows.Count; ++j)
|
||||
{
|
||||
var docParagraph = new Paragraph();
|
||||
var docRun = new Run();
|
||||
var runProperties = new RunProperties();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(data[i].Rows[j].Item2));
|
||||
|
||||
runProperties.AppendChild(new RunFonts() { Ascii = "Times New Roman", ComplexScript = "Times New Roman", HighAnsi = "Times New Roman" });
|
||||
runProperties.AppendChild(new FontSize { Val = data[i].Rows[j].Item2.Size == null ? data[i].Rows[j].Item2.Size : "24" });
|
||||
if (data[i].Rows[j].Item2.Bold)
|
||||
runProperties.AppendChild(new Bold());
|
||||
|
||||
docRun.AppendChild(runProperties);
|
||||
docRun.AppendChild(new Text { Text = data[i].Rows[j].Item1.ToString(), Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
TableCell docCell = new TableCell();
|
||||
docCell.AppendChild(docParagraph);
|
||||
docRow.AppendChild(docCell);
|
||||
}
|
||||
table.AppendChild(docRow);
|
||||
}
|
||||
_docBody.AppendChild(table);
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
|
||||
protected override void SaveWord(WordInfo info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
||||
public int VendorId { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public Dictionary<int, (IBuildModel, int)> PurchaseBuilds { get; set; } = new();
|
||||
public Dictionary<int, (IProductModel, int)> PurchaseProducts { get; set; } = new();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ComputerHardwareStoreContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IBuildLogic
|
||||
{
|
||||
List<BuildViewModel>? ReadList(BuildSearchModel? model);
|
||||
BuildViewModel? ReadElement(BuildSearchModel model);
|
||||
bool Create(BuildBindingModel model);
|
||||
bool Update(BuildBindingModel model);
|
||||
bool Delete(BuildBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ICommentLogic
|
||||
{
|
||||
List<CommentViewModel>? ReadList(CommentSearchModel? model);
|
||||
CommentViewModel? ReadElement(CommentSearchModel model);
|
||||
bool Create(CommentBindingModel model);
|
||||
bool Update(CommentBindingModel model);
|
||||
bool Delete(CommentBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IPurchaseLogic
|
||||
{
|
||||
List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model);
|
||||
PurchaseViewModel? ReadElement(PurchaseSearchModel model);
|
||||
bool Create(PurchaseBindingModel model);
|
||||
bool Update(PurchaseBindingModel model);
|
||||
bool Delete(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение списка товаров по сборкам
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportProductBuildViewModel> GetProductBuild();
|
||||
/// <summary>
|
||||
/// Получение списка сборок по товарам
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportBuildProductViewModel> GetBuildProduct();
|
||||
/// <summary>
|
||||
/// Получение списка покупок за период с комплектующими и комментариями
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
//List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Получение списка комплектующих с покупками и заказами за период
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
//List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение списка в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveListToWordFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение списка в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveListToExcelFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ using ComputerHardwareStoreContracts.ViewModels;
|
||||
|
||||
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStoreKeeperLogic
|
||||
public interface IStoreKeeperLogic
|
||||
{
|
||||
List<StoreKeeperViewModel>? ReadList(StoreKeeperSearchModel? model);
|
||||
StoreKeeperViewModel? ReadElement(StoreKeeperSearchModel model);
|
||||
bool Create(StoreKeeperBindingModel model);
|
||||
bool Update(StoreKeeperBindingModel model);
|
||||
bool Delete(StoreKeeperBindingModel model);
|
||||
}
|
||||
List<StoreKeeperViewModel>? ReadList(StoreKeeperSearchModel? model);
|
||||
StoreKeeperViewModel? ReadElement(StoreKeeperSearchModel model);
|
||||
bool Create(StoreKeeperBindingModel model);
|
||||
bool Update(StoreKeeperBindingModel model);
|
||||
bool Delete(StoreKeeperBindingModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,6 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="BusinessLogicsContracts\IStoreKeeperLogic.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="BusinessLogicsContracts\IStoreKeeperLogic.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerHardwareStoreDataModels\ComputerHardwareStoreDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
public class BuildSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int VendorId { get; set; }
|
||||
public int? ProductId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,5 @@
|
||||
public class CommentSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int? StoreKeeperId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,7 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int StoreKeeperId { get; set; }
|
||||
public int? BuildId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
public class PurchaseSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? VendorId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,6 +4,5 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Login { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ComputerHardwareStoreContracts.ViewModels.HelperModels
|
||||
{
|
||||
public class ComponentSelectionViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
public double Cost { get; set; }
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public int VendorId { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
public Dictionary<int, (IBuildModel, int)> PurchaseBuilds { get; set; } = new();
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> PurchaseProducts { get; set; } = new();
|
||||
public Dictionary<int, (IProductModel, int)> PurchaseProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ComputerHardwareStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportBuildProductViewModel
|
||||
{
|
||||
public string BuildName { get; set; } = string.Empty;
|
||||
public List<(string Product, int Price)> Products { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ComputerHardwareStoreContracts.ViewModels
|
||||
{
|
||||
public class ReportProductBuildViewModel
|
||||
{
|
||||
public string ProductName { get; set;} = string.Empty;
|
||||
public List<(string Build, int Price)> Builds { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
{
|
||||
string Name { get; }
|
||||
double Price { get; }
|
||||
public IStoreKeeperModel StoreKeeper { get; }
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
int VendorId { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
public Dictionary<int, (IBuildModel, int)> PurchaseBuilds { get; }
|
||||
public Dictionary<int, (IProductModel, int)> PurchaseProducts { get; }
|
||||
}
|
||||
|
||||
@@ -7,27 +7,14 @@ namespace ComputerHardwareStoreDatabaseImplement
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
/*
|
||||
* в program добавить:
|
||||
* // получаем строку подключения из файла конфигурации
|
||||
* string connection = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
*
|
||||
* // добавляем контекст ApplicationContext в качестве сервиса в приложение
|
||||
* builder.Services.AddDbContext<ApplicationContext>(options => options.UseSqlServer(connection));
|
||||
*
|
||||
* в appsettings:
|
||||
* "ConnectionStrings": {
|
||||
* "DefaultConnection": "Host=localhost;Database=ProductBar_db;Username=compstore;Password=compstore"
|
||||
* },
|
||||
*/
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
//optionsBuilder.UseNpgsql("Host=192.168.1.61:5432;Database=computerhardwarestore;Username=compstore;Password=compstore");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=ComputerHardwareStore;Username=postgres;Password=postgres");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
public virtual DbSet<Product> Products { set; get; }
|
||||
public virtual DbSet<ProductComponent> ProductComponents { set; get; }
|
||||
|
||||
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
|
||||
public virtual DbSet<Build> Builds { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class BuildStorage : IBuildStorage
|
||||
{
|
||||
public List<BuildViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Builds
|
||||
.Include(b => b.Comments)
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.Include(b => b.Vendor)
|
||||
.Select(b => b.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<BuildViewModel> GetFilteredList(BuildSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Builds
|
||||
// только те, что созданы пользователем
|
||||
.Include(b => b.Vendor)
|
||||
.Where(b => b.Vendor.Id == model.VendorId
|
||||
// если есть хотя бы 1 общий компонент с товарами
|
||||
&& !model.ProductId.HasValue || b.Components.FirstOrDefault(
|
||||
c => c.Component.ProductComponents.FirstOrDefault(
|
||||
p => p.ProductId == model.ProductId)
|
||||
!= null)
|
||||
!= null)
|
||||
// вместе с комментами
|
||||
.Include(b => b.Comments)
|
||||
// вместе с компонентами
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.Select(b => b.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public BuildViewModel? GetElement(BuildSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Builds
|
||||
.Include(b => b.Vendor)
|
||||
.Where(b => b.Vendor.Id == model.VendorId)
|
||||
.Include(b => b.Comments)
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.FirstOrDefault(b =>
|
||||
(!string.IsNullOrEmpty(model.Name) && b.Name == model.Name) ||
|
||||
(model.Id.HasValue && b.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public BuildViewModel? Insert(BuildBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newBuild = Build.Create(context, model);
|
||||
if (newBuild == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Builds.Add(newBuild);
|
||||
context.SaveChanges();
|
||||
return context.Builds
|
||||
.Include(b => b.Vendor)
|
||||
.Include(b => b.Comments)
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.FirstOrDefault(p => p.Id == newBuild.Id)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public BuildViewModel? Update(BuildBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var build = context.Builds
|
||||
.Include(b => b.Comments)
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.Include(b => b.Vendor)
|
||||
.Where(b => b.Vendor.Id == model.Vendor.Id)
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
if (build == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Update(model);
|
||||
context.SaveChanges();
|
||||
return build.GetViewModel;
|
||||
}
|
||||
public BuildViewModel? Delete(BuildBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var build = context.Builds
|
||||
.Include(b => b.Comments)
|
||||
.Include(b => b.Components)
|
||||
.ThenInclude(b => b.Component)
|
||||
.Include(b => b.Vendor)
|
||||
.Where(b => b.Vendor.Id == model.Vendor.Id)
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
if (build == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Builds.Remove(build);
|
||||
context.SaveChanges();
|
||||
return build.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class CommentStorage : ICommentStorage
|
||||
{
|
||||
public List<CommentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Comments
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CommentViewModel> GetFilteredList(CommentSearchModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Comments
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public CommentViewModel? GetElement(CommentSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Comments
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public CommentViewModel? Insert(CommentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newComment = Comment.Create(model);
|
||||
if (newComment == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Comments.Add(newComment);
|
||||
context.SaveChanges();
|
||||
return newComment.GetViewModel;
|
||||
}
|
||||
public CommentViewModel? Update(CommentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Comments.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
public CommentViewModel? Delete(CommentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Comments.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Comments.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Components
|
||||
.Select(x => x.GetViewModel)
|
||||
.Select(c => c.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new ();
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Components
|
||||
.Where(x => x.Name.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.Where(c => c.Name.Contains(model.Name) ||
|
||||
(c.StoreKeeper.Id == model.StoreKeeperId))
|
||||
.Select(c => c.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -37,17 +38,16 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Components
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Name)
|
||||
&& x.Name == model.Name)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
.FirstOrDefault(c =>
|
||||
(!string.IsNullOrEmpty(model.Name) && c .Name == model.Name) ||
|
||||
(model.Id.HasValue && c.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newComponent = Component.Create(context, model);
|
||||
var newComponent = Component.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
@@ -59,27 +59,27 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
var element = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
var element = context.Components.FirstOrDefault(c => c.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
context.Components.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
context.Components.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Select(o => o.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.Where(o =>
|
||||
(model.Id.HasValue && o.Id == model.Id) ||
|
||||
((model.DateFrom.HasValue && model.DateTo.HasValue) &&
|
||||
((model.DateFrom <= o.DateCreate && o.DateCreate <= model.DateTo) ||
|
||||
(o.DateImplement.HasValue && o.DateCreate < model.DateFrom && model.DateFrom < o.DateImplement)))
|
||||
)
|
||||
.Select(o => o.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newOrder = Order.Create(context, model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var order = context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Orders
|
||||
.Include(o => o.Products)
|
||||
.ThenInclude(o => o.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class ProductStorage : IProductStorage
|
||||
{
|
||||
public List<ProductViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Products
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.Select(p => p.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Products
|
||||
.Where(p => (p.StoreKeeper.Id == model.StoreKeeperId)
|
||||
// есть хотя бы 1 общий со сборкой компонент
|
||||
&& (!model.BuildId.HasValue || p.Components.FirstOrDefault
|
||||
(c => c.Component.BuldComponents.FirstOrDefault(
|
||||
b => b.BuildId == model.BuildId)
|
||||
!= null)
|
||||
!= null))
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.Select(p => p.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ProductViewModel? GetElement(ProductSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Products
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.FirstOrDefault(p =>
|
||||
(!string.IsNullOrEmpty(model.Name) && p.Name == model.Name) ||
|
||||
(model.Id.HasValue && p.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ProductViewModel? Insert(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newProduct = Product.Create(context, model);
|
||||
if (newProduct == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Products.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return context.Products
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.FirstOrDefault(p => p.Id == newProduct.Id)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ProductViewModel? Update(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var product = context.Products
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Update(model);
|
||||
context.SaveChanges();
|
||||
return product.GetViewModel;
|
||||
}
|
||||
|
||||
public ProductViewModel? Delete(ProductBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var product = context.Products
|
||||
.Include(p => p.Components)
|
||||
.ThenInclude(p => p.Component)
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Products.Remove(product);
|
||||
context.SaveChanges();
|
||||
return product.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class PurchaseStorage : IPurchaseStorage
|
||||
{
|
||||
public List<PurchaseViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Purchases
|
||||
.Include(p => p.Builds)
|
||||
.ThenInclude(p => p.Build)
|
||||
.Include(p => p.Products)
|
||||
.ThenInclude(p => p.Product)
|
||||
.Select(p => p.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Purchases
|
||||
.Include(p => p.Builds)
|
||||
.ThenInclude(p => p.Build)
|
||||
.Include(p => p.Products)
|
||||
.ThenInclude(p => p.Product)
|
||||
.Where(p =>
|
||||
(model.VendorId.HasValue && model.VendorId == p.VendorId) ||
|
||||
(model.Id.HasValue && p.Id == model.Id) ||
|
||||
((model.DateFrom.HasValue && model.DateTo.HasValue) &&
|
||||
((model.DateFrom <= p.DateCreate && p.DateCreate <= model.DateTo) ||
|
||||
(p.DateImplement.HasValue && p.DateCreate < model.DateFrom && model.DateFrom < p.DateImplement)))
|
||||
)
|
||||
.Select(p => p.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Purchases
|
||||
.Include(p => p.Builds)
|
||||
.ThenInclude(p => p.Build)
|
||||
.Include(p => p.Products)
|
||||
.ThenInclude(p => p.Product)
|
||||
.FirstOrDefault(p => p.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Insert(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newPurchase = Purchase.Create(context, model);
|
||||
if (newPurchase == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Purchases.Add(newPurchase);
|
||||
context.SaveChanges();
|
||||
return newPurchase.GetViewModel;
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Update(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var purchase = context.Purchases
|
||||
.Include(p => p.Builds)
|
||||
.ThenInclude(p => p.Build)
|
||||
.Include(p => p.Products)
|
||||
.ThenInclude(p => p.Product)
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
if (purchase == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
purchase.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public PurchaseViewModel? Delete(PurchaseBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Purchases
|
||||
.Include(p => p.Builds)
|
||||
.ThenInclude(p => p.Build)
|
||||
.Include(p => p.Products)
|
||||
.ThenInclude(p => p.Product)
|
||||
.FirstOrDefault(o => o.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Purchases.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class StoreKeeperStorage : IStoreKeeperStorage
|
||||
{
|
||||
public StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.StoreKeepers
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Login)
|
||||
&& x.Login == model.Login)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<StoreKeeperViewModel> GetFilteredList(StoreKeeperSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.StoreKeepers
|
||||
.Where(x => x.Login.Contains(model.Login))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<StoreKeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.StoreKeepers
|
||||
.Include(x => x.Components)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel? Insert(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newStoreKeeper = StoreKeeper.Create(context, model);
|
||||
if (newStoreKeeper == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.StoreKeepers.Add(newStoreKeeper);
|
||||
context.SaveChanges();
|
||||
return newStoreKeeper.GetViewModel;
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel? Update(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.StoreKeepers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
public StoreKeeperViewModel? Delete(StoreKeeperBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.StoreKeepers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.StoreKeepers.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDatabaseImplement.Models;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Implements
|
||||
{
|
||||
public class VendorStorage : IVendorStorage
|
||||
{
|
||||
public VendorViewModel? GetElement(VendorSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Vendors
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Login)
|
||||
&& x.Login == model.Login)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<VendorViewModel> GetFilteredList(VendorSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Vendors
|
||||
.Where(x => x.Login.Contains(model.Login))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<VendorViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
return context.Vendors
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public VendorViewModel? Insert(VendorBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var newVendor = Vendor.Create(context, model);
|
||||
if (newVendor == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Vendors.Add(newVendor);
|
||||
context.SaveChanges();
|
||||
return newVendor.GetViewModel;
|
||||
}
|
||||
|
||||
public VendorViewModel? Update(VendorBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Vendors.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
public VendorViewModel? Delete(VendorBindingModel model)
|
||||
{
|
||||
using var context = new ComputerHardwareStoreDBContext();
|
||||
var element = context.Vendors.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Vendors.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerHardwareStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerHardwareStoreDBContext))]
|
||||
[Migration("20240528172646_create")]
|
||||
partial class create
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("VendorId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VendorId");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("BuildComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int?>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int?>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("VendorId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VendorId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseProduct", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StoreKeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Vendor", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Vendors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Vendor", "Vendor")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("VendorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Vendor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("BuldComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", "StoreKeeperЗЛ")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeperЗЛ");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ProductId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", null)
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("StoreKeeperId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ProductComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Vendor", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("VendorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("BuldComponents");
|
||||
|
||||
b.Navigation("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Vendor", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class create : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StoreKeepers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Login = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_StoreKeepers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Vendors",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Login = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Vendors", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Components_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false),
|
||||
StoreKeeperId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_StoreKeepers_StoreKeeperId",
|
||||
column: x => x.StoreKeeperId,
|
||||
principalTable: "StoreKeepers",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Builds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false),
|
||||
VendorId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Builds", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Builds_Vendors_VendorId",
|
||||
column: x => x.VendorId,
|
||||
principalTable: "Vendors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
VendorId = table.Column<int>(type: "integer", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Vendors_VendorId",
|
||||
column: x => x.VendorId,
|
||||
principalTable: "Vendors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BuildComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BuildComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildComponents_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Comments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Date = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Text = table.Column<string>(type: "text", nullable: false),
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Comments_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseBuilds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseBuilds", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseBuilds_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseBuilds_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseProducts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseProducts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseProducts_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseProducts_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderProducts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderProducts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProducts_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderProducts_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BuildComponents_BuildId",
|
||||
table: "BuildComponents",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BuildComponents_ComponentId",
|
||||
table: "BuildComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Builds_VendorId",
|
||||
table: "Builds",
|
||||
column: "VendorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Comments_BuildId",
|
||||
table: "Comments",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Components_StoreKeeperId",
|
||||
table: "Components",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderProducts_OrderId",
|
||||
table: "OrderProducts",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderProducts_ProductId",
|
||||
table: "OrderProducts",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ProductId",
|
||||
table: "Orders",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ComponentId",
|
||||
table: "ProductComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ProductId",
|
||||
table: "ProductComponents",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_StoreKeeperId",
|
||||
table: "Products",
|
||||
column: "StoreKeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseBuilds_BuildId",
|
||||
table: "PurchaseBuilds",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseBuilds_PurchaseId",
|
||||
table: "PurchaseBuilds",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseProducts_ProductId",
|
||||
table: "PurchaseProducts",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseProducts_PurchaseId",
|
||||
table: "PurchaseProducts",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_VendorId",
|
||||
table: "Purchases",
|
||||
column: "VendorId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BuildComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Comments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderProducts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseBuilds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseProducts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Builds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Vendors");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "StoreKeepers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,563 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerHardwareStoreDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerHardwareStoreDBContext))]
|
||||
partial class ComputerHardwareStoreDBContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("VendorId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VendorId");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("BuildComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int?>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int?>("StoreKeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StoreKeeperId");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("VendorId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VendorId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseProduct", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchaseProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StoreKeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Vendor", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Vendors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Vendor", "Vendor")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("VendorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Vendor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("BuldComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", "StoreKeeperЗЛ")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("StoreKeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("StoreKeeperЗЛ");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ProductId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", null)
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("StoreKeeperId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.ProductComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ProductComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Vendor", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("VendorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.PurchaseProduct", b =>
|
||||
{
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerHardwareStoreDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("BuldComponents");
|
||||
|
||||
b.Navigation("ProductComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerHardwareStoreDatabaseImplement.Models.Vendor", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
@@ -16,7 +14,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
private Dictionary<int, (IComponentModel, int)>? _buildComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> BuildComponents
|
||||
@@ -77,7 +75,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Price = model.Price;
|
||||
}
|
||||
|
||||
public BuildViewModel GetViewModel() => new()
|
||||
public BuildViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public string Text { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public int BuildId { get; set; }
|
||||
public virtual Build Build { get; set; } = new();
|
||||
public static Comment? Create(CommentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
||||
@@ -14,13 +14,15 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||
public virtual StoreKeeper? StoreKeeperЗЛ { get; set; }
|
||||
[NotMapped]
|
||||
IStoreKeeperModel IComponentModel.StoreKeeper => throw new NotImplementedException();
|
||||
public IStoreKeeperModel? StoreKeeper { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
||||
public static Component? Create(ComputerHardwareStoreDBContext context, ComponentBindingModel model)
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<BuildComponent> BuldComponents { get; set; } = new();
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@@ -31,7 +33,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost,
|
||||
StoreKeeper = context.StoreKeepers.First(x => x.Id == model.StoreKeeper.Id)
|
||||
StoreKeeper = model.StoreKeeper
|
||||
};
|
||||
}
|
||||
public void Update (ComponentBindingModel model)
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[NotMapped]
|
||||
IStoreKeeperModel IProductModel.StoreKeeper => StoreKeeper;
|
||||
public virtual StoreKeeper StoreKeeper {get; set;} = new();
|
||||
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents
|
||||
@@ -61,7 +64,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Price = Price,
|
||||
ProductComponents = ProductComponents
|
||||
ProductComponents = ProductComponents,
|
||||
StoreKeeper = StoreKeeper,
|
||||
};
|
||||
|
||||
public static void UpdateComponents(ComputerHardwareStoreDBContext context, ProductBindingModel model)
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; set; } = null;
|
||||
private Dictionary<int, (IBuildModel, int)>? _purchaseBuilds = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IBuildModel, int)> PurchaseBuilds
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class BuildController : Controller
|
||||
{
|
||||
private readonly ILogger<BuildController> _logger;
|
||||
private readonly IBuildStorage _storage;
|
||||
|
||||
public BuildController(ILogger<BuildController> logger, IBuildStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] BuildSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] BuildSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] BuildBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] BuildBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] BuildBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class CommentController : Controller
|
||||
{
|
||||
private readonly ILogger<CommentController> _logger;
|
||||
private readonly ICommentStorage _storage;
|
||||
|
||||
public CommentController(ILogger<CommentController> logger, ICommentStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] CommentSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] CommentSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] CommentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] CommentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] CommentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ProductController : Controller
|
||||
{
|
||||
private readonly ILogger<ProductController> _logger;
|
||||
private readonly IProductStorage _storage;
|
||||
|
||||
public ProductController(ILogger<ProductController> logger, IProductStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] ProductSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] ProductSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] ProductBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] ProductBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] ProductBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class OrderController : Controller
|
||||
{
|
||||
private readonly ILogger<OrderController> _logger;
|
||||
private readonly IOrderStorage _storage;
|
||||
|
||||
public OrderController(ILogger<OrderController> logger, IOrderStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] OrderSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] OrderSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] OrderBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ComponentController : Controller
|
||||
{
|
||||
private readonly ILogger<ComponentController> _logger;
|
||||
private readonly IComponentStorage _storage;
|
||||
|
||||
public ComponentController(ILogger<ComponentController> logger, IComponentStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] ComponentSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] ComponentSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] ComponentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] ComponentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] ComponentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class PurchaseController : Controller
|
||||
{
|
||||
private readonly ILogger<PurchaseController> _logger;
|
||||
private readonly IPurchaseStorage _storage;
|
||||
|
||||
public PurchaseController(ILogger<PurchaseController> logger, IPurchaseStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] PurchaseSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] PurchaseSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] PurchaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] PurchaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] PurchaseBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class StoreKeepersController : Controller
|
||||
{
|
||||
private readonly ILogger<StoreKeepersController> _logger;
|
||||
private readonly IStoreKeeperStorage _storage;
|
||||
|
||||
public StoreKeepersController(ILogger<StoreKeepersController> logger, IStoreKeeperStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] StoreKeeperSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] StoreKeeperSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] StoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] StoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] StoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerHardwareStoreREST.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class VendorController : Controller
|
||||
{
|
||||
private readonly ILogger<VendorController> _logger;
|
||||
private readonly IVendorStorage _storage;
|
||||
|
||||
public VendorController(ILogger<VendorController> logger, IVendorStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
[HttpPost("get/filter")]
|
||||
public IActionResult GetByFilter([FromBody] VendorSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetFilteredList(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("get")]
|
||||
public IActionResult GetById([FromBody] VendorSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.GetElement(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("create")]
|
||||
public IActionResult Create([FromBody] VendorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Insert(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPut("update")]
|
||||
public IActionResult Update([FromBody] VendorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Update(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost("delete")]
|
||||
public IActionResult Delete([FromBody] VendorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _storage.Delete(model);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs
Normal file
52
ComputerHardwareStore/ComputerHardwareStoreREST/Program.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using ComputerHardwareStoreBusinessLogic.BusinessLogic;
|
||||
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
|
||||
using ComputerHardwareStoreContracts.StorageContracts;
|
||||
using ComputerHardwareStoreDatabaseImplement;
|
||||
using ComputerHardwareStoreDatabaseImplement.Implements;
|
||||
using ComputerHardwareStoreREST;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// получаем строку подключения из файла конфигурации
|
||||
//DBSetting.ConectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
|
||||
builder.Services.AddTransient<IVendorStorage, VendorStorage>();
|
||||
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
||||
builder.Services.AddTransient<IBuildStorage, BuildStorage>();
|
||||
builder.Services.AddTransient<ICommentStorage, CommentStorage>();
|
||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
builder.Services.AddTransient<IStoreKeeperStorage, StoreKeeperStorage>();
|
||||
|
||||
builder.Services.AddTransient<IVendorLogic, VendorLogic>();
|
||||
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
||||
builder.Services.AddTransient<IBuildLogic, BuildLogic>();
|
||||
builder.Services.AddTransient<ICommentLogic, CommentLogic>();
|
||||
//builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
builder.Services.AddTransient<IStoreKeeperLogic, StoreKeeperLogic>();
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"profiles": {
|
||||
"ComputerHardwareStoreREST": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:8080;http://localhost:8081"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<environment names="Development">
|
||||
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
|
||||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
|
||||
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
|
||||
asp-fallback-test="window.jQuery && window.jQuery.validator"
|
||||
crossorigin="anonymous"
|
||||
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
|
||||
</script>
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
|
||||
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
|
||||
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
|
||||
crossorigin="anonymous"
|
||||
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
|
||||
</script>
|
||||
</environment>
|
||||
@@ -0,0 +1,43 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Login" class="control-label"></label>
|
||||
<input asp-for="Login" class="form-control" />
|
||||
<span asp-validation-for="Login" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"></label>
|
||||
<input asp-for="Password" class="form-control" />
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Login)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Password)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Login)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Password)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit" asp-route-id="@Model?.Id">Edit</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
@model ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>StoreKeeper</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label"></label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Login" class="control-label"></label>
|
||||
<input asp-for="Login" class="form-control" />
|
||||
<span asp-validation-for="Login" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"></label>
|
||||
<input asp-for="Password" class="form-control" />
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
@model IEnumerable<ComputerHardwareStoreDatabaseImplement.Models.StoreKeeper>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Index</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Login)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Password)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Login)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Password)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="d:/temp/HardwareShopRestApi.log" />
|
||||
<appendToFile value="true" />
|
||||
<maximumFileSize value="100KB" />
|
||||
<maxSizeRollBackups value="2" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="TRACE" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</log4net>
|
||||
43
ComputerHardwareStore/StoreKeeperClient/APIClient.cs
Normal file
43
ComputerHardwareStore/StoreKeeperClient/APIClient.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace StoreKeeperClient
|
||||
{
|
||||
public static class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static StoreKeeperViewModel? Client { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.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 = _client.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using StoreKeeperClient.Models;
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
|
||||
namespace StoreKeeperClient.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/main/getpurchases?clientId={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.Client);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Privacy(string login, string password, string fio)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIClient.PostRequest("api/client/updatedata", new StoreKeeperBindingModel
|
||||
{
|
||||
Id = APIClient.Client.Id,
|
||||
Name = fio,
|
||||
Login = login,
|
||||
Password = password
|
||||
});
|
||||
APIClient.Client.Name = fio;
|
||||
APIClient.Client.Login = login;
|
||||
APIClient.Client.Password = password;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult AddBuildToPurchase()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Builds()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<BuildViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult BuildUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CommentUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Comments()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<CommentViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ProductsList()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<BuildViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult PurchaseCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult PurchaseDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Purchases()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<PurchaseViewModel>());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult PurchaseUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View(new List<PurchaseViewModel>());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Report(string password)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
Response.Redirect("ReportOnly");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
|
||||
using ComputerHardwareStoreContracts.SearchModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels.HelperModels;
|
||||
using ComputerHardwareStoreDataModels.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace StoreKeeperClient.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class StoreKeeperController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IStoreKeeperLogic _storeKeeperLogic;
|
||||
private readonly IComponentLogic _componentLogic;
|
||||
private readonly IBuildLogic _buildLogic;
|
||||
private readonly IProductLogic _productLogic;
|
||||
|
||||
public StoreKeeperController(ILogger<HomeController> logger, IComponentLogic componentLogic, IBuildLogic buildLogic, IProductLogic productLogic, IStoreKeeperLogic storeKeeperLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_componentLogic = componentLogic;
|
||||
_buildLogic = buildLogic;
|
||||
_productLogic = productLogic;
|
||||
_storeKeeperLogic = storeKeeperLogic;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateComponent(string name, double price)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Enter name");
|
||||
}
|
||||
_componentLogic.Create(
|
||||
new ComponentBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Cost = price,
|
||||
StoreKeeper = APIClient.Client!
|
||||
}
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult UpdateComponent()
|
||||
{
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateComponent(int component, double price, string name)
|
||||
{
|
||||
if (component == 0)
|
||||
{
|
||||
throw new Exception("Chose component");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Enter name");
|
||||
}
|
||||
_componentLogic.Update(
|
||||
new ComponentBindingModel
|
||||
{
|
||||
Id = component,
|
||||
Name = name,
|
||||
Cost = price,
|
||||
StoreKeeper = APIClient.Client!
|
||||
}
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ComponentToBuild()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Assemblies = _buildLogic.ReadList(null);
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ComponentToBuild(int buildId, int componentId, int count)
|
||||
{
|
||||
if (buildId == 0)
|
||||
{
|
||||
throw new Exception("chose build");
|
||||
}
|
||||
if (componentId == 0)
|
||||
{
|
||||
throw new Exception("chose component");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("chose count");
|
||||
}
|
||||
BuildViewModel build = _buildLogic.ReadElement(new BuildSearchModel { Id = buildId })!;
|
||||
ComponentViewModel component = _componentLogic.ReadElement(new ComponentSearchModel { Id = componentId })!;
|
||||
if (build.BuildComponents.ContainsKey(componentId))
|
||||
build.BuildComponents[componentId] = (component, build.BuildComponents[componentId].Item2 + count);
|
||||
else
|
||||
build.BuildComponents.Add(componentId, (component, count));
|
||||
build.Price += component.Cost * count;
|
||||
_buildLogic.Update(
|
||||
new BuildBindingModel
|
||||
{
|
||||
Id = buildId,
|
||||
Vendor = build.Vendor,
|
||||
Name = build.Name,
|
||||
Price = build.Price,
|
||||
BuildComponents = build.BuildComponents
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult RemoveComponentFromBuild()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Assemblies = _buildLogic.ReadList(null);
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void RemoveComponentFromBuild(int buildId, int componentId, int count)
|
||||
{
|
||||
if (buildId == 0)
|
||||
{
|
||||
throw new Exception("chose build");
|
||||
}
|
||||
if (componentId == 0)
|
||||
{
|
||||
throw new Exception("chose component");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("chose count");
|
||||
}
|
||||
BuildViewModel build = _buildLogic.ReadElement(new BuildSearchModel { Id = buildId })!;
|
||||
ComponentViewModel component = _componentLogic.ReadElement(new ComponentSearchModel { Id = componentId })!;
|
||||
if (build.BuildComponents.ContainsKey(componentId))
|
||||
{
|
||||
if (build.BuildComponents[componentId].Item2 < count)
|
||||
throw new Exception("ther is not enough components in build");
|
||||
if (build.BuildComponents[componentId].Item2 == count)
|
||||
build.BuildComponents.Remove(componentId);
|
||||
else
|
||||
build.BuildComponents[componentId] = (component, build.BuildComponents[componentId].Item2 - count);
|
||||
}
|
||||
else
|
||||
throw new Exception("there is no that component in build");
|
||||
build.Price -= component.Cost * count;
|
||||
_buildLogic.Update(
|
||||
new BuildBindingModel
|
||||
{
|
||||
Id = buildId,
|
||||
Vendor = build.Vendor,
|
||||
Name = build.Name,
|
||||
Price = build.Price,
|
||||
BuildComponents = build.BuildComponents
|
||||
});
|
||||
Response.Redirect("Components");
|
||||
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult DeleteComponent()
|
||||
{
|
||||
ViewBag.Components = _componentLogic.ReadList(
|
||||
new ComponentSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client.Id
|
||||
}
|
||||
);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteComponent(int component)
|
||||
{
|
||||
if (component == 0)
|
||||
{
|
||||
throw new Exception("Chose component");
|
||||
}
|
||||
_componentLogic.Delete(
|
||||
new ComponentBindingModel { Id = component }
|
||||
);
|
||||
Response.Redirect("Components");
|
||||
}
|
||||
|
||||
// товары
|
||||
[HttpGet]
|
||||
public IActionResult CreateProduct()
|
||||
{
|
||||
return View(_componentLogic.ReadList(null));
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateProduct(double price, string name, List<ComponentSelectionViewModel> components)
|
||||
{
|
||||
var selectedComponents = components.Where(g => g.IsSelected && g.Quantity > 0).ToList();
|
||||
List<ComponentViewModel> componentsViewModels = _componentLogic.ReadList(null)!;
|
||||
Dictionary<int, (IComponentModel, int)> productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
price = 0;
|
||||
foreach (var component in selectedComponents)
|
||||
{
|
||||
productComponents.Add(component.Id, (
|
||||
componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!,
|
||||
component.Quantity
|
||||
));
|
||||
price += component.Quantity * componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!.Cost;
|
||||
|
||||
}
|
||||
_productLogic.Create(
|
||||
new ProductBindingModel
|
||||
{
|
||||
Name = name,
|
||||
Price = price,
|
||||
StoreKeeper = APIClient.Client!,
|
||||
ProductComponents = productComponents,
|
||||
}
|
||||
);
|
||||
Response.Redirect("Products");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult UpdateProduct(int productId)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?clientId={APIClient.Client.Id}");
|
||||
return View(productId);
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateProduct(double price, string name, List<ComponentSelectionViewModel> components, int product)
|
||||
{
|
||||
if (product == 0)
|
||||
{
|
||||
throw new Exception("chose product");
|
||||
}
|
||||
var selectedComponents = components.Where(g => g.IsSelected && g.Quantity > 0).ToList();
|
||||
List<ComponentViewModel> componentsViewModels = _componentLogic.ReadList(null)!;
|
||||
Dictionary<int, (IComponentModel, int)> productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
price = 0;
|
||||
// добавляем в
|
||||
foreach (var component in selectedComponents)
|
||||
{
|
||||
productComponents.Add(component.Id, (
|
||||
componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!,
|
||||
component.Quantity
|
||||
));
|
||||
price += component.Quantity * componentsViewModels.FirstOrDefault(x => x.Id == component.Id)!.Cost;
|
||||
}
|
||||
_productLogic.Update(
|
||||
new ProductBindingModel
|
||||
{
|
||||
Id = product,
|
||||
StoreKeeper = APIClient.Client,
|
||||
Price = price,
|
||||
Name = name,
|
||||
ProductComponents = productComponents
|
||||
});
|
||||
Response.Redirect("Products");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteProduct()
|
||||
{
|
||||
var products = _productLogic.ReadList(
|
||||
new ProductSearchModel
|
||||
{
|
||||
StoreKeeperId = APIClient.Client!.Id
|
||||
}
|
||||
);
|
||||
ViewBag.Products = products;
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteProduct(int product)
|
||||
{
|
||||
_productLogic.Delete(
|
||||
new ProductBindingModel { Id = product }
|
||||
);
|
||||
Response.Redirect("Products");
|
||||
}
|
||||
|
||||
// заказы
|
||||
|
||||
//[HttpGet]
|
||||
//public IActionResult CreateOrder()
|
||||
//{
|
||||
// ViewBag.Products = _productLogic.ReadList(
|
||||
// new ProductSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void CreateOrder(DateTime date, string address, int product)
|
||||
//{
|
||||
// _orderForProductsLogic.Create(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// OrderDate = date,
|
||||
// DeliveryAddres = address,
|
||||
// ProductId = product,
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
//[HttpGet]
|
||||
//public IActionResult UpdateOrder()
|
||||
//{
|
||||
// ViewBag.Products = _productLogic.ReadList(
|
||||
// new ProductSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// ViewBag.OrdersForProducts = _orderForProductsLogic.ReadList(
|
||||
// new OrderForProductsSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void UpdateOrder(DateTime date, string address, int product, int order)
|
||||
//{
|
||||
// _orderForProductsLogic.Update(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// Id = order,
|
||||
// OrderDate = date,
|
||||
// DeliveryAddres = address,
|
||||
// ProductId = product
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
|
||||
//[HttpGet]
|
||||
//public IActionResult DeleteOrder()
|
||||
//{
|
||||
// ViewBag.OrdersForProducts = _orderForProductsLogic.ReadList(
|
||||
// new OrderForProductsSearchModel
|
||||
// {
|
||||
// StoreKeeperId = APIClient.Client!.Id
|
||||
// }
|
||||
// );
|
||||
// return View();
|
||||
//}
|
||||
//[HttpPost]
|
||||
//public void DeleteOrder(int order)
|
||||
//{
|
||||
// _orderForProductsLogic.Delete(
|
||||
// new OrderForProductsBindingModel
|
||||
// {
|
||||
// Id = order,
|
||||
// }
|
||||
// );
|
||||
// Response.Redirect("Orders");
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace StoreKeeperClient.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
||||
25
ComputerHardwareStore/StoreKeeperClient/Program.cs
Normal file
25
ComputerHardwareStore/StoreKeeperClient/Program.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StoreKeeperClient;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:34433",
|
||||
"sslPort": 44361
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5062",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7291;http://localhost:5062",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\StoreKeeperController.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.rtl.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-grid.rtl.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.rtl.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-reboot.rtl.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-utilities.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-utilities.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-utilities.rtl.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-utilities.rtl.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.rtl.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.rtl.min.css.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.min.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.bundle.min.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.esm.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.esm.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.esm.min.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.esm.min.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.min.js" />
|
||||
<None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.min.js.map" />
|
||||
<None Include="wwwroot\lib\bootstrap\LICENSE" />
|
||||
<None Include="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.min.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation\dist\additional-methods.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation\dist\additional-methods.min.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation\dist\jquery.validate.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation\dist\jquery.validate.min.js" />
|
||||
<None Include="wwwroot\lib\jquery-validation\LICENSE.md" />
|
||||
<None Include="wwwroot\lib\jquery\dist\jquery.js" />
|
||||
<None Include="wwwroot\lib\jquery\dist\jquery.min.js" />
|
||||
<None Include="wwwroot\lib\jquery\dist\jquery.min.map" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ComputerHardwareStoreContracts\ComputerHardwareStoreContracts.csproj" />
|
||||
<ProjectReference Include="..\ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@StoreKeeperCLient_HostAddress = http://localhost:5062
|
||||
|
||||
GET {{StoreKeeperCLient_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,53 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<ProductViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "BuildsByProductsReport";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Сборки по товарам</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<form method="post">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в профиль</h3>
|
||||
return;
|
||||
}
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Формат сохранения:</div>
|
||||
<div class="col-8">
|
||||
<input type="radio" id="xlc" name="saveFormat" value="xlc">
|
||||
<label for="xlc">XLC</label>
|
||||
<input type="radio" id="doc" name="saveFormat" value="doc">
|
||||
<label for="doc">DOC</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Выберите файл:</div>
|
||||
<div class="col-8">
|
||||
<input type="file" id="fileSave" name="fileSave" style="display:none">
|
||||
<button type="button" onclick="document.getElementById('fileSave').click();">Выбрать файл</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Выберите товары:</div>
|
||||
<div class="col-8">
|
||||
<select name="products" multiple>
|
||||
@foreach (var product in Model)
|
||||
{
|
||||
<option value="@product.Id">@product.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить список" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "ComponentToBuild";
|
||||
}
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="display-4">Добавить комплектующие в сборку</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Сборка:</div>
|
||||
<div class="col-8 ">
|
||||
<select id="buildId" name="buildId" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases,"Id", "BuildName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Комплектующее:</div>
|
||||
<div class="col-8">
|
||||
<select id="componentId" name="componentId" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ComponentName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Количество:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="count" id="count" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Добавить" class="btn btn-success" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,58 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<ComponentViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Components";
|
||||
}
|
||||
<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 class="text-decoration-none me-3 text-black h5" asp-action="CreateComponent">Создать комплектующее</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateComponent">Изменить комплектующее</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="ComponentToBuild">Привязать комплектующее к сборке</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="DeleteComponent">Удалить комплектующее</a>
|
||||
</p>
|
||||
|
||||
<table class="componentTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
@foreach (var component in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => component.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => component.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => component.Cost)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,58 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<ComponentViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "ComponentsByPurchasesAndOrdersReport";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Отчёт по комплектующим</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<form method="post">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в профиль</h3>
|
||||
return;
|
||||
}
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Формат получения:</div>
|
||||
<div class="col-8">
|
||||
<input type="radio" id="email" name="saveFormat" value="email">
|
||||
<label for="email">почта</label>
|
||||
<input type="radio" id="site" name="saveFormat" value="site">
|
||||
<label for="site">на сайте</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Начальная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="startDate" name="startDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Конечная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="endDate" name="endDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Выберите комплектующие:</div>
|
||||
<div class="col-8">
|
||||
<select name="components" multiple>
|
||||
@foreach (var component in Model)
|
||||
{
|
||||
<option value="@component.Id">@component.Id @component.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="получить отчёт" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateComponent";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Создать комплектующее</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" id="componentName" name="componentName" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="number" id="componentPrice" name="componentPrice" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateOrder";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Создать заказ</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8"><input type="number" id="date" name="date" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Адрес доставки:</div>
|
||||
<div class="col-8"><input type="text" id="address" name="address" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Товар:</div>
|
||||
<div class="col-8">
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,36 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<ComponentViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "CreateProduct";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Создать товар</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" id="productName" name="productName" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="number" id="productPrice" name="productPrice" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Комплектующие:</div>
|
||||
<div class="col-8">
|
||||
<select name="components" multiple>
|
||||
@foreach (var component in Model)
|
||||
{
|
||||
<option value="@component.Id">@component.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteComponent";
|
||||
}
|
||||
<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="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"Id", "Name"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Удалить" class="btn btn-danger" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteOrder";
|
||||
}
|
||||
<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="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders,"Id", "DateCreate"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Удалить" class="btn btn-danger" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteProduct";
|
||||
}
|
||||
<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="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "Name"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Удалить" class="btn btn-danger" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -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="text" name="login" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btnprimary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,64 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Create">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Изделие
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,57 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Orders";
|
||||
}
|
||||
<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 class="text-decoration-none me-3 text-black h5" asp-action="CreateOrder">Создать заказ</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateOrder">Изменить заказ</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="DeleteOrder">Удалить заказе</a>
|
||||
</p>
|
||||
|
||||
<table class="OrderTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Дата выполнения
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
@foreach (var order in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,58 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<ProductViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Products";
|
||||
}
|
||||
<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 class="text-decoration-none me-3 text-black h5" asp-action="CreateProduct">Создать товар</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateProduct">Изменить товар</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="DeleteProduct">Удалить товар</a>
|
||||
</p>
|
||||
|
||||
<table class="productTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
@foreach (var Product in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Product.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Product.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => Product.Price)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
@using ComputerHardwareStoreContracts.ViewModels
|
||||
@model List<PurchaseViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Purchases";
|
||||
}
|
||||
<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 class="text-decoration-none me-3 text-black h5" asp-action="CreatePurchase">Создать покупку</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdatePurchase">Изменить покупку</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="DeletePurchase">Удалить покупку</a>
|
||||
</p>
|
||||
|
||||
<table class="PurchaseTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Дата выполнения
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody>
|
||||
@foreach (var purchase in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => purchase.DateImplement)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="storeKeeperName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="login" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Регистрация"
|
||||
class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user