Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,4 @@ FodyWeavers.xsd
/src/BookStore.Presentation/MVC/wwwroot/BookPhoto
/src/BookStore.Presentation/MVC/wwwroot/Books
/src/BookStore.Presentation/MVC/wwwroot/UserProfileImage
/ConsoleApp1
17 changes: 12 additions & 5 deletions BookStore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E63592A0-27C4-4444-BD76-903F182458F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Domain", "src\BookStore.Domain\BookStore.Domain.csproj", "{6E8888F1-9B76-421E-ACEF-A499B3D04927}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Domain", "src\BookStore.Domain\BookStore.Domain.csproj", "{6E8888F1-9B76-421E-ACEF-A499B3D04927}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Application", "src\BookStore.Application\BookStore.Application.csproj", "{D22C7023-F7E3-468C-AEA1-37B97C680D15}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Application", "src\BookStore.Application\BookStore.Application.csproj", "{D22C7023-F7E3-468C-AEA1-37B97C680D15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookStore.Infrastructure", "src\BookStore.Infrastructure\BookStore.Infrastructure.csproj", "{B6A4EF17-870B-4BF7-AAAE-FDC55E5831ED}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore.Infrastructure", "src\BookStore.Infrastructure\BookStore.Infrastructure.csproj", "{B6A4EF17-870B-4BF7-AAAE-FDC55E5831ED}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BookStore.Presentation", "BookStore.Presentation", "{3F32713F-015A-4919-93CA-E1A5B34B4863}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "src\BookStore.Presentation\API\API.csproj", "{A71B8C92-ACA9-40D5-B277-E4CA6D2E195D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "src\BookStore.Presentation\API\API.csproj", "{A71B8C92-ACA9-40D5-B277-E4CA6D2E195D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVC", "src\BookStore.Presentation\MVC\MVC.csproj", "{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVC", "src\BookStore.Presentation\MVC\MVC.csproj", "{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{216E730C-ACC0-4053-A332-713E53440962}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -43,6 +45,10 @@ Global
{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9}.Release|Any CPU.Build.0 = Release|Any CPU
{216E730C-ACC0-4053-A332-713E53440962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{216E730C-ACC0-4053-A332-713E53440962}.Debug|Any CPU.Build.0 = Debug|Any CPU
{216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.ActiveCfg = Release|Any CPU
{216E730C-ACC0-4053-A332-713E53440962}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -54,6 +60,7 @@ Global
{3F32713F-015A-4919-93CA-E1A5B34B4863} = {E63592A0-27C4-4444-BD76-903F182458F1}
{A71B8C92-ACA9-40D5-B277-E4CA6D2E195D} = {3F32713F-015A-4919-93CA-E1A5B34B4863}
{34FD9F69-7D8B-4762-BFF3-11DE5C98CFE9} = {3F32713F-015A-4919-93CA-E1A5B34B4863}
{216E730C-ACC0-4053-A332-713E53440962} = {E63592A0-27C4-4444-BD76-903F182458F1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C5D27F3-0D32-4A29-AE50-8C54EE56B386}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Mapster;
using MediatR;
using Microsoft.AspNetCore.Hosting;
using System.IO;

namespace BookStore.Application.useCases.Authors.Commands
{
Expand All @@ -24,18 +25,30 @@ public async Task<Author> Handle(CreateAuthorCommand command, CancellationToken
string fileName = "";
try
{
var newFilePath = "";
fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
filePath = Path.Combine(_webHostEnvironment.WebRootPath, "AuthorsProfileImage", fileName);

using (var stream = new FileStream(filePath, FileMode.Create))

if (!Directory.Exists(newFilePath))
{
await file.CopyToAsync(stream);
for (int i = 0; i < filePath.Split("\\").Length; i++)
{
if (i + 1 != filePath.Split("\\").Length)
newFilePath += filePath.Split("\\")[i] + "\\";
}

Directory.CreateDirectory(newFilePath);
}
}
catch (Exception ex)

using (var stream = new FileStream(filePath, FileMode.Create))
await file.CopyToAsync(stream);

} catch (Exception ex)
{
await Console.Out.WriteLineAsync($"Error: {ex.Message}");
}

var author = command.Adapt<Author>();
author.PhotoPath = "/AuthorsProfileImage/" + fileName;
var res = await _context.Authors.AddAsync(author);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,36 @@ public async Task<Book> Handle(CreateBookCommand request, CancellationToken canc

try
{
var newFilePath = "";

fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
filePath = Path.Combine(_webHostEnvironment.WebRootPath, "Books", fileName);

PhotofileName = Guid.NewGuid().ToString() + Path.GetExtension(PhotoFile.FileName);
PhotofilePath = Path.Combine(_webHostEnvironment.WebRootPath, "BookPhoto", PhotofileName);

if (!Directory.Exists(filePath))
{
for (int i = 0; i < filePath.Split("\\").Length; i++)
{
if (i + 1 != filePath.Split("\\").Length)
newFilePath += filePath.Split("\\")[i] + "\\";
}

Directory.CreateDirectory(newFilePath);
}

if (!Directory.Exists(PhotofilePath))
{
newFilePath = "";
for (int i = 0; i < PhotofilePath.Split("\\").Length; i++)
{
if (i + 1 != PhotofilePath.Split("\\").Length)
newFilePath += PhotofilePath.Split("\\")[i] + "\\";
}

Directory.CreateDirectory(newFilePath);
}

using (var stream = new FileStream(filePath, FileMode.Create))
{
Expand Down
6 changes: 0 additions & 6 deletions src/BookStore.Presentation/MVC/MVC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@
<ProjectReference Include="..\..\BookStore.Infrastructure\BookStore.Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\AuthorsProfileImage\" />
<Folder Include="wwwroot\BookPhoto\" />
<Folder Include="wwwroot\UserProfileImage\" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/BookStore.Presentation/MVC/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5197",
"launchBrowser": false,
"applicationUrl": "http://localhost:5189",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
3 changes: 2 additions & 1 deletion src/BookStore.Presentation/MVC/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"BotToken": "7040566448:AAGuJLoJsg8xqAAW4yWGPkZDR6PIxBlU0ns",
"ConnectionStrings": {
"SQLServer": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BookStore.MVC.DB;",
"Postgres": "Host=localhost;Port=5432;Username=postgres;Password=sardor0618!;Database=BookStoree.DB"
"Postgres": "Host=localhost;Port=5432;Username=postgres;Password=coder;Database=BookStore.Db"
},
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
Expand All @@ -26,5 +26,6 @@
}
}
]

}
}