Repository: CodeMazeBlog/.NET-Core-Series
Branch: master
Commit: 929da1e94d61
Files: 115
Total size: 75.7 KB
Directory structure:
gitextract_2hk3m77t/
├── .gitignore
├── Part 1/
│ ├── Schema.mwb
│ ├── Schema.mwb.bak
│ └── init.sql
├── Part 2/
│ └── AccountOwnerServer/
│ ├── AccountOwnerServer/
│ │ ├── AccountOwnerServer.csproj
│ │ ├── Controllers/
│ │ │ └── WeatherForecastController.cs
│ │ ├── Extensions/
│ │ │ └── ServiceExtensions.cs
│ │ ├── Program.cs
│ │ ├── Properties/
│ │ │ └── launchSettings.json
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ └── AccountOwnerServer.sln
├── Part 3/
│ └── AccountOwnerServer/
│ ├── AccountOwnerServer/
│ │ ├── AccountOwnerServer.csproj
│ │ ├── Controllers/
│ │ │ └── WeatherForecastController.cs
│ │ ├── Extensions/
│ │ │ └── ServiceExtensions.cs
│ │ ├── Program.cs
│ │ ├── Properties/
│ │ │ └── launchSettings.json
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ └── nlog.config
│ ├── AccountOwnerServer.sln
│ ├── Contracts/
│ │ ├── Contracts.csproj
│ │ └── ILoggerManager.cs
│ └── LoggerService/
│ ├── LoggerManager.cs
│ └── LoggerService.csproj
├── Part 4/
│ └── AccountOwnerServer/
│ ├── AccountOwnerServer/
│ │ ├── AccountOwnerServer.csproj
│ │ ├── Controllers/
│ │ │ └── WeatherForecastController.cs
│ │ ├── Extensions/
│ │ │ └── ServiceExtensions.cs
│ │ ├── Program.cs
│ │ ├── Properties/
│ │ │ └── launchSettings.json
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ └── nlog.config
│ ├── AccountOwnerServer.sln
│ ├── Contracts/
│ │ ├── Contracts.csproj
│ │ ├── IAccountRepository.cs
│ │ ├── ILoggerManager.cs
│ │ ├── IOwnerRepository.cs
│ │ ├── IRepositoryBase.cs
│ │ └── IRepositoryWrapper.cs
│ ├── Entities/
│ │ ├── Entities.csproj
│ │ ├── Models/
│ │ │ ├── Account.cs
│ │ │ └── Owner.cs
│ │ └── RepositoryContext.cs
│ ├── LoggerService/
│ │ ├── LoggerManager.cs
│ │ └── LoggerService.csproj
│ └── Repository/
│ ├── AccountRepository.cs
│ ├── OwnerRepository.cs
│ ├── Repository.csproj
│ ├── RepositoryBase.cs
│ └── RepositoryWrapper.cs
├── Part 5/
│ └── AccountOwnerServer/
│ ├── AccountOwnerServer/
│ │ ├── AccountOwnerServer.csproj
│ │ ├── Controllers/
│ │ │ └── OwnerController.cs
│ │ ├── Extensions/
│ │ │ └── ServiceExtensions.cs
│ │ ├── MappingProfile.cs
│ │ ├── Program.cs
│ │ ├── Properties/
│ │ │ └── launchSettings.json
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ └── nlog.config
│ ├── AccountOwnerServer.sln
│ ├── Contracts/
│ │ ├── Contracts.csproj
│ │ ├── IAccountRepository.cs
│ │ ├── ILoggerManager.cs
│ │ ├── IOwnerRepository.cs
│ │ ├── IRepositoryBase.cs
│ │ └── IRepositoryWrapper.cs
│ ├── Entities/
│ │ ├── DataTransferObjects/
│ │ │ ├── AccountDto.cs
│ │ │ └── OwnerDto.cs
│ │ ├── Entities.csproj
│ │ ├── Models/
│ │ │ ├── Account.cs
│ │ │ └── Owner.cs
│ │ └── RepositoryContext.cs
│ ├── LoggerService/
│ │ ├── LoggerManager.cs
│ │ └── LoggerService.csproj
│ └── Repository/
│ ├── AccountRepository.cs
│ ├── OwnerRepository.cs
│ ├── Repository.csproj
│ ├── RepositoryBase.cs
│ └── RepositoryWrapper.cs
├── Part 6/
│ └── AccountOwnerServer/
│ ├── AccountOwnerServer/
│ │ ├── AccountOwnerServer.csproj
│ │ ├── Controllers/
│ │ │ └── OwnerController.cs
│ │ ├── Extensions/
│ │ │ └── ServiceExtensions.cs
│ │ ├── MappingProfile.cs
│ │ ├── Program.cs
│ │ ├── Properties/
│ │ │ └── launchSettings.json
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.json
│ │ └── nlog.config
│ ├── AccountOwnerServer.sln
│ ├── Contracts/
│ │ ├── Contracts.csproj
│ │ ├── IAccountRepository.cs
│ │ ├── ILoggerManager.cs
│ │ ├── IOwnerRepository.cs
│ │ ├── IRepositoryBase.cs
│ │ └── IRepositoryWrapper.cs
│ ├── Entities/
│ │ ├── DataTransferObjects/
│ │ │ ├── AccountDto.cs
│ │ │ ├── OwnerDto.cs
│ │ │ ├── OwnerForCreationDto.cs
│ │ │ └── OwnerForUpdateDto.cs
│ │ ├── Entities.csproj
│ │ ├── Models/
│ │ │ ├── Account.cs
│ │ │ └── Owner.cs
│ │ └── RepositoryContext.cs
│ ├── LoggerService/
│ │ ├── LoggerManager.cs
│ │ └── LoggerService.csproj
│ └── Repository/
│ ├── AccountRepository.cs
│ ├── OwnerRepository.cs
│ ├── Repository.csproj
│ ├── RepositoryBase.cs
│ └── RepositoryWrapper.cs
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/Part 3/.vs
/Part 3/AccountOwnerServer/obj
/Part 3/AccountOwnerServer/AccountOwnerServer.csproj.user
/Part 3/AccountOwnerServer/bin
/Part 3/Contracts/obj
/Part 3/Contracts/bin
/Part 3/LoggerService/obj
/Part 3/LoggerService/bin
*.suo
*.user
_ReSharper.*
bin
obj
packages
/Part 4/Contracts/obj
/Part 4/Contracts/bin
/Part 4/Entities/obj
/Part 4/Entities/bin
/Part 4/LoggerService/obj
/Part 4/LoggerService/bin
/Part 4/Repository/obj
/Part 4/Repository/bin
/Part7/.vscode
Projects
/Part 3/AccountOwnerServer/Projects
/Part 5/AccountOwnerServer/Projects
/Part 4/AccountOwnerServer/Projects
/Part 6/AccountOwnerServer/Projects
/Part 5 - Update - OwnersByName/.vs
/Part 4/.vs
/Part 5/.vs
/Part 2/AccountOwnerServer/.vs
/Part 6/.vs
/Part 16/.NET Core part - end/.vs
/Part 17/.NET Core part - end/.vs
================================================
FILE: Part 1/init.sql
================================================
-- MySQL Script generated by MySQL Workbench
-- Wed Jan 22 11:12:09 2025
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema AccountOwner
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema AccountOwner
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `AccountOwner` DEFAULT CHARACTER SET utf8 ;
USE `AccountOwner` ;
-- -----------------------------------------------------
-- Table `AccountOwner`.`Owner`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `AccountOwner`.`Owner` ;
CREATE TABLE IF NOT EXISTS `AccountOwner`.`Owner` (
`OwnerId` CHAR(36) NOT NULL,
`Name` NVARCHAR(60) NOT NULL,
`DateOfBirth` DATE NOT NULL,
`Address` NVARCHAR(100) NOT NULL,
PRIMARY KEY (`OwnerId`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `AccountOwner`.`Account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `AccountOwner`.`Account` ;
CREATE TABLE IF NOT EXISTS `AccountOwner`.`Account` (
`AccountID` CHAR(36) NOT NULL,
`DateCreated` DATE NOT NULL,
`AccountType` NVARCHAR(45) NOT NULL,
`OwnerId` CHAR(36) NOT NULL,
PRIMARY KEY (`AccountID`),
INDEX `fk_Account_Owner_idx` (`OwnerId` ASC) VISIBLE,
CONSTRAINT `fk_Account_Owner`
FOREIGN KEY (`OwnerId`)
REFERENCES `AccountOwner`.`Owner` (`OwnerId`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
================================================
using Microsoft.AspNetCore.Mvc;
namespace AccountOwnerServer.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
================================================
namespace AccountOwnerServer.Extensions
{
public static class ServiceExtensions
{
public static void ConfigureCors(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public static void ConfigureIISIntegration(this IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
}
}
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Program.cs
================================================
using AccountOwnerServer.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.ConfigureCors();
builder.Services.ConfigureIISIntegration();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.All
});
app.UseCors("CorsPolicy");
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40700",
"sslPort": 44360
}
},
"profiles": {
"AccountOwnerServer": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
================================================
namespace AccountOwnerServer
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
================================================
FILE: Part 2/AccountOwnerServer/AccountOwnerServer.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{0213FB50-5C53-4C34-8B2C-E515C7DC2579}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8E1F895-37AB-455B-8D05-ED495BE48F88}
EndGlobalSection
EndGlobal
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LoggerService\LoggerService.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
================================================
using Contracts;
using Microsoft.AspNetCore.Mvc;
namespace AccountOwnerServer.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly ILoggerManager _logger;
public WeatherForecastController(ILoggerManager logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<string> Get()
{
_logger.LogInfo("Here is info message from the controller.");
_logger.LogDebug("Here is debug message from the controller.");
_logger.LogWarn("Here is warn message from the controller.");
_logger.LogError("Here is error message from the controller.");
return new string[] { "value1", "value2" };
}
}
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
================================================
using Contracts;
using LoggerService;
namespace AccountOwnerServer.Extensions
{
public static class ServiceExtensions
{
public static void ConfigureCors(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public static void ConfigureIISIntegration(this IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
}
public static void ConfigureLoggerService(this IServiceCollection services)
{
services.AddSingleton<ILoggerManager, LoggerManager>();
}
}
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Program.cs
================================================
using AccountOwnerServer.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using NLog;
var builder = WebApplication.CreateBuilder(args);
LogManager.Setup().LoadConfigurationFromFile(string.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
builder.Services.ConfigureCors();
builder.Services.ConfigureIISIntegration();
builder.Services.ConfigureLoggerService();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.All
});
app.UseCors("CorsPolicy");
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40700",
"sslPort": 44360
}
},
"profiles": {
"AccountOwnerServer": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
================================================
namespace AccountOwnerServer
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/nlog.config
================================================
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="d:Projects\Blog-AccountOwner\Project\internal_logs\internallog.txt">
<targets>
<target name="logfile" xsi:type="File"
fileName="d:/Projects/Blog-AccountOwner/Project/logs/${shortdate}_logfile.txt"
layout="${longdate} ${level:uppercase=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
================================================
FILE: Part 3/AccountOwnerServer/AccountOwnerServer.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{0213FB50-5C53-4C34-8B2C-E515C7DC2579}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{B731D3C2-9A89-40E4-B96B-AA300B4195BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoggerService", "LoggerService\LoggerService.csproj", "{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.Build.0 = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.Build.0 = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8E1F895-37AB-455B-8D05-ED495BE48F88}
EndGlobalSection
EndGlobal
================================================
FILE: Part 3/AccountOwnerServer/Contracts/Contracts.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
================================================
FILE: Part 3/AccountOwnerServer/Contracts/ILoggerManager.cs
================================================
namespace Contracts
{
public interface ILoggerManager
{
void LogInfo(string message);
void LogWarn(string message);
void LogDebug(string message);
void LogError(string message);
}
}
================================================
FILE: Part 3/AccountOwnerServer/LoggerService/LoggerManager.cs
================================================
using Contracts;
using NLog;
namespace LoggerService
{
public class LoggerManager : ILoggerManager
{
private static ILogger logger = LogManager.GetCurrentClassLogger();
public void LogDebug(string message) => logger.Debug(message);
public void LogError(string message) => logger.Error(message);
public void LogInfo(string message) => logger.Info(message);
public void LogWarn(string message) => logger.Warn(message);
}
}
================================================
FILE: Part 3/AccountOwnerServer/LoggerService/LoggerService.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LoggerService\LoggerService.csproj" />
<ProjectReference Include="..\Repository\Repository.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
================================================
using Contracts;
using Microsoft.AspNetCore.Mvc;
namespace AccountOwnerServer.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private IRepositoryWrapper _repository;
public WeatherForecastController(IRepositoryWrapper repository)
{
_repository = repository;
}
[HttpGet]
public IEnumerable<string> Get()
{
var domesticAccounts = _repository.Account.FindByCondition(x => x.AccountType.Equals("Domestic"));
var owners = _repository.Owner.FindAll();
return new string[] { "value1", "value2" };
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
================================================
using Contracts;
using LoggerService;
using Microsoft.EntityFrameworkCore;
using Entities;
using Repository;
namespace AccountOwnerServer.Extensions
{
public static class ServiceExtensions
{
public static void ConfigureCors(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public static void ConfigureIISIntegration(this IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
}
public static void ConfigureLoggerService(this IServiceCollection services)
{
services.AddSingleton<ILoggerManager, LoggerManager>();
}
public static void ConfigureMySqlContext(this IServiceCollection services, IConfiguration config)
{
var connectionString = config["mysqlconnection:connectionString"];
services.AddDbContext<RepositoryContext>(o => o.UseMySql(connectionString,
MySqlServerVersion.LatestSupportedServerVersion));
}
public static void ConfigureRepositoryWrapper(this IServiceCollection services)
{
services.AddScoped<IRepositoryWrapper, RepositoryWrapper>();
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Program.cs
================================================
using AccountOwnerServer.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using NLog;
var builder = WebApplication.CreateBuilder(args);
LogManager.Setup().LoadConfigurationFromFile(string.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
builder.Services.ConfigureCors();
builder.Services.ConfigureIISIntegration();
builder.Services.ConfigureLoggerService();
builder.Services.ConfigureMySqlContext(builder.Configuration);
builder.Services.ConfigureRepositoryWrapper();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.All
});
app.UseCors("CorsPolicy");
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40700",
"sslPort": 44360
}
},
"profiles": {
"AccountOwnerServer": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
================================================
namespace AccountOwnerServer
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"mysqlconnection": {
"connectionString": "server=localhost;userid=root;password=yourpass;database=accountowner;"
},
"AllowedHosts": "*"
}
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/nlog.config
================================================
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="d:Projects\Blog-AccountOwner\Project\internal_logs\internallog.txt">
<targets>
<target name="logfile" xsi:type="File"
fileName="d:/Projects/Blog-AccountOwner/Project/logs/${shortdate}_logfile.txt"
layout="${longdate} ${level:uppercase=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
================================================
FILE: Part 4/AccountOwnerServer/AccountOwnerServer.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{0213FB50-5C53-4C34-8B2C-E515C7DC2579}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{B731D3C2-9A89-40E4-B96B-AA300B4195BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoggerService", "LoggerService\LoggerService.csproj", "{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{16AAE663-A20E-493D-9087-F4F4016F6216}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.Build.0 = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.Build.0 = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.Build.0 = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.Build.0 = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8E1F895-37AB-455B-8D05-ED495BE48F88}
EndGlobalSection
EndGlobal
================================================
FILE: Part 4/AccountOwnerServer/Contracts/Contracts.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/Contracts/IAccountRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IAccountRepository : IRepositoryBase<Account>
{
}
}
================================================
FILE: Part 4/AccountOwnerServer/Contracts/ILoggerManager.cs
================================================
namespace Contracts
{
public interface ILoggerManager
{
void LogInfo(string message);
void LogWarn(string message);
void LogDebug(string message);
void LogError(string message);
}
}
================================================
FILE: Part 4/AccountOwnerServer/Contracts/IOwnerRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IOwnerRepository : IRepositoryBase<Owner>
{
}
}
================================================
FILE: Part 4/AccountOwnerServer/Contracts/IRepositoryBase.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Contracts
{
public interface IRepositoryBase<T>
{
IQueryable<T> FindAll();
IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
void Create(T entity);
void Update(T entity);
void Delete(T entity);
}
}
================================================
FILE: Part 4/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace Contracts
{
public interface IRepositoryWrapper
{
IOwnerRepository Owner { get; }
IAccountRepository Account { get; }
void Save();
}
}
================================================
FILE: Part 4/AccountOwnerServer/Entities/Entities.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/Entities/Models/Account.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("account")]
public class Account
{
public Guid AccountId { get; set; }
[Required(ErrorMessage = "Date created is required")]
public DateTime DateCreated { get; set; }
[Required(ErrorMessage = "Account type is required")]
public string? AccountType { get; set; }
[ForeignKey(nameof(Owner))]
public Guid OwnerId { get; set; }
public Owner? Owner { get; set; }
}
}
================================================
FILE: Part 4/AccountOwnerServer/Entities/Models/Owner.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("owner")]
public class Owner
{
public Guid OwnerId { get; set; }
[Required(ErrorMessage = "Name is required")]
[StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]
public string? Name { get; set; }
[Required(ErrorMessage = "Date of birth is required")]
public DateTime DateOfBirth { get; set; }
[Required(ErrorMessage = "Address is required")]
[StringLength(100, ErrorMessage = "Address cannot be loner then 100 characters")]
public string? Address { get; set; }
public ICollection<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 4/AccountOwnerServer/Entities/RepositoryContext.cs
================================================
using Entities.Models;
using Microsoft.EntityFrameworkCore;
namespace Entities
{
public class RepositoryContext : DbContext
{
public RepositoryContext(DbContextOptions options)
: base(options)
{
}
public DbSet<Owner>? Owners { get; set; }
public DbSet<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 4/AccountOwnerServer/LoggerService/LoggerManager.cs
================================================
using Contracts;
using NLog;
namespace LoggerService
{
public class LoggerManager : ILoggerManager
{
private static ILogger logger = LogManager.GetCurrentClassLogger();
public void LogDebug(string message) => logger.Debug(message);
public void LogError(string message) => logger.Error(message);
public void LogInfo(string message) => logger.Info(message);
public void LogWarn(string message) => logger.Warn(message);
}
}
================================================
FILE: Part 4/AccountOwnerServer/LoggerService/LoggerService.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/Repository/AccountRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
namespace Repository
{
public class AccountRepository : RepositoryBase<Account>, IAccountRepository
{
public AccountRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/Repository/OwnerRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
namespace Repository
{
public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
{
public OwnerRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
}
}
================================================
FILE: Part 4/AccountOwnerServer/Repository/Repository.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 4/AccountOwnerServer/Repository/RepositoryBase.cs
================================================
using Contracts;
using Entities;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;
namespace Repository
{
public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : class
{
protected RepositoryContext RepositoryContext { get; set; }
public RepositoryBase(RepositoryContext repositoryContext)
{
RepositoryContext = repositoryContext;
}
public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTracking();
public IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression) =>
RepositoryContext.Set<T>().Where(expression).AsNoTracking();
public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
public void Update(T entity) => RepositoryContext.Set<T>().Update(entity);
public void Delete(T entity) => RepositoryContext.Set<T>().Remove(entity);
}
}
================================================
FILE: Part 4/AccountOwnerServer/Repository/RepositoryWrapper.cs
================================================
using Contracts;
using Entities;
namespace Repository
{
public class RepositoryWrapper : IRepositoryWrapper
{
private RepositoryContext _repoContext;
private IOwnerRepository _owner;
private IAccountRepository _account;
public IOwnerRepository Owner
{
get
{
if (_owner == null)
{
_owner = new OwnerRepository(_repoContext);
}
return _owner;
}
}
public IAccountRepository Account
{
get
{
if (_account == null)
{
_account = new AccountRepository(_repoContext);
}
return _account;
}
}
public RepositoryWrapper(RepositoryContext repositoryContext)
{
_repoContext = repositoryContext;
}
public void Save()
{
_repoContext.SaveChanges();
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LoggerService\LoggerService.csproj" />
<ProjectReference Include="..\Repository\Repository.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs
================================================
using AutoMapper;
using Contracts;
using Entities.DataTransferObjects;
using Microsoft.AspNetCore.Mvc;
namespace AccountOwnerServer.Controllers
{
[Route("api/owner")]
[ApiController]
public class OwnerController : ControllerBase
{
private ILoggerManager _logger;
private IRepositoryWrapper _repository;
private IMapper _mapper;
public OwnerController(ILoggerManager logger, IRepositoryWrapper repository, IMapper mapper)
{
_logger = logger;
_repository = repository;
_mapper = mapper;
}
[HttpGet]
public IActionResult GetAllOwners()
{
try
{
var owners = _repository.Owner.GetAllOwners();
_logger.LogInfo($"Returned all owners from database.");
var ownersResult = _mapper.Map<IEnumerable<OwnerDto>>(owners);
return Ok(ownersResult);
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetAllOwners action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpGet("{id}")]
public IActionResult GetOwnerById(Guid id)
{
try
{
var owner = _repository.Owner.GetOwnerById(id);
if (owner is null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
else
{
_logger.LogInfo($"Returned owner with id: {id}");
var ownerResult = _mapper.Map<OwnerDto>(owner);
return Ok(ownerResult);
}
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetOwnerById action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpGet("{id}/account")]
public IActionResult GetOwnerWithDetails(Guid id)
{
try
{
var owner = _repository.Owner.GetOwnerWithDetails(id);
if (owner == null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
else
{
_logger.LogInfo($"Returned owner with details for id: {id}");
var ownerResult = _mapper.Map<OwnerDto>(owner);
return Ok(ownerResult);
}
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetOwnerWithDetails action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
================================================
using Contracts;
using LoggerService;
using Microsoft.EntityFrameworkCore;
using Entities;
using Repository;
namespace AccountOwnerServer.Extensions
{
public static class ServiceExtensions
{
public static void ConfigureCors(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public static void ConfigureIISIntegration(this IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
}
public static void ConfigureLoggerService(this IServiceCollection services)
{
services.AddSingleton<ILoggerManager, LoggerManager>();
}
public static void ConfigureMySqlContext(this IServiceCollection services, IConfiguration config)
{
var connectionString = config["mysqlconnection:connectionString"];
services.AddDbContext<RepositoryContext>(o => o.UseMySql(connectionString,
MySqlServerVersion.LatestSupportedServerVersion));
}
public static void ConfigureRepositoryWrapper(this IServiceCollection services)
{
services.AddScoped<IRepositoryWrapper, RepositoryWrapper>();
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs
================================================
using AutoMapper;
using Entities.DataTransferObjects;
using Entities.Models;
using System.Linq;
namespace AccountOwnerServer
{
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Owner, OwnerDto>();
CreateMap<Account, AccountDto>();
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Program.cs
================================================
using AccountOwnerServer.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using NLog;
var builder = WebApplication.CreateBuilder(args);
LogManager.Setup().LoadConfigurationFromFile(string.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
builder.Services.ConfigureCors();
builder.Services.ConfigureIISIntegration();
builder.Services.ConfigureLoggerService();
builder.Services.ConfigureMySqlContext(builder.Configuration);
builder.Services.ConfigureRepositoryWrapper();
builder.Services.AddAutoMapper(typeof(Program));
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.All
});
app.UseCors("CorsPolicy");
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40700",
"sslPort": 44360
}
},
"profiles": {
"AccountOwnerServer": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"mysqlconnection": {
"connectionString": "server=localhost;userid=root;password=yourpass;database=accountowner;"
},
"AllowedHosts": "*"
}
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/nlog.config
================================================
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="d:Projects\Blog-AccountOwner\Project\internal_logs\internallog.txt">
<targets>
<target name="logfile" xsi:type="File"
fileName="d:/Projects/Blog-AccountOwner/Project/logs/${shortdate}_logfile.txt"
layout="${longdate} ${level:uppercase=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
================================================
FILE: Part 5/AccountOwnerServer/AccountOwnerServer.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{0213FB50-5C53-4C34-8B2C-E515C7DC2579}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{B731D3C2-9A89-40E4-B96B-AA300B4195BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoggerService", "LoggerService\LoggerService.csproj", "{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{16AAE663-A20E-493D-9087-F4F4016F6216}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.Build.0 = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.Build.0 = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.Build.0 = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.Build.0 = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8E1F895-37AB-455B-8D05-ED495BE48F88}
EndGlobalSection
EndGlobal
================================================
FILE: Part 5/AccountOwnerServer/Contracts/Contracts.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 5/AccountOwnerServer/Contracts/IAccountRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IAccountRepository
{
}
}
================================================
FILE: Part 5/AccountOwnerServer/Contracts/ILoggerManager.cs
================================================
namespace Contracts
{
public interface ILoggerManager
{
void LogInfo(string message);
void LogWarn(string message);
void LogDebug(string message);
void LogError(string message);
}
}
================================================
FILE: Part 5/AccountOwnerServer/Contracts/IOwnerRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IOwnerRepository
{
IEnumerable<Owner> GetAllOwners();
Owner GetOwnerById(Guid ownerId);
Owner GetOwnerWithDetails(Guid ownerId);
}
}
================================================
FILE: Part 5/AccountOwnerServer/Contracts/IRepositoryBase.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Contracts
{
public interface IRepositoryBase<T>
{
IQueryable<T> FindAll();
IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
void Create(T entity);
void Update(T entity);
void Delete(T entity);
}
}
================================================
FILE: Part 5/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace Contracts
{
public interface IRepositoryWrapper
{
IOwnerRepository Owner { get; }
IAccountRepository Account { get; }
void Save();
}
}
================================================
FILE: Part 5/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs
================================================
using System;
namespace Entities.DataTransferObjects
{
public class AccountDto
{
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public string? AccountType { get; set; }
}
}
================================================
FILE: Part 5/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs
================================================
namespace Entities.DataTransferObjects
{
public class OwnerDto
{
public Guid Id { get; set; }
public string? Name { get; set; }
public DateTime DateOfBirth { get; set; }
public string? Address { get; set; }
public IEnumerable<AccountDto>? Accounts { get; set; }
}
}
================================================
FILE: Part 5/AccountOwnerServer/Entities/Entities.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
</ItemGroup>
</Project>
================================================
FILE: Part 5/AccountOwnerServer/Entities/Models/Account.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("account")]
public class Account
{
[Column("AccountId")]
public Guid Id { get; set; }
[Required(ErrorMessage = "Date created is required")]
public DateTime DateCreated { get; set; }
[Required(ErrorMessage = "Account type is required")]
public string? AccountType { get; set; }
[ForeignKey(nameof(Owner))]
public Guid OwnerId { get; set; }
public Owner? Owner { get; set; }
}
}
================================================
FILE: Part 5/AccountOwnerServer/Entities/Models/Owner.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("owner")]
public class Owner
{
[Column("OwnerId")]
public Guid Id { get; set; }
[Required(ErrorMessage = "Name is required")]
[StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]
public string? Name { get; set; }
[Required(ErrorMessage = "Date of birth is required")]
public DateTime DateOfBirth { get; set; }
[Required(ErrorMessage = "Address is required")]
[StringLength(100, ErrorMessage = "Address cannot be loner then 100 characters")]
public string? Address { get; set; }
public ICollection<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 5/AccountOwnerServer/Entities/RepositoryContext.cs
================================================
using Entities.Models;
using Microsoft.EntityFrameworkCore;
namespace Entities
{
public class RepositoryContext : DbContext
{
public RepositoryContext(DbContextOptions options)
: base(options)
{
}
public DbSet<Owner>? Owners { get; set; }
public DbSet<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 5/AccountOwnerServer/LoggerService/LoggerManager.cs
================================================
using Contracts;
using NLog;
namespace LoggerService
{
public class LoggerManager : ILoggerManager
{
private static ILogger logger = LogManager.GetCurrentClassLogger();
public void LogDebug(string message) => logger.Debug(message);
public void LogError(string message) => logger.Error(message);
public void LogInfo(string message) => logger.Info(message);
public void LogWarn(string message) => logger.Warn(message);
}
}
================================================
FILE: Part 5/AccountOwnerServer/LoggerService/LoggerService.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 5/AccountOwnerServer/Repository/AccountRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
namespace Repository
{
public class AccountRepository : RepositoryBase<Account>, IAccountRepository
{
public AccountRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/Repository/OwnerRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
using Microsoft.EntityFrameworkCore;
namespace Repository
{
public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
{
public OwnerRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
public IEnumerable<Owner> GetAllOwners()
{
return FindAll()
.OrderBy(ow => ow.Name)
.ToList();
}
public Owner GetOwnerById(Guid ownerId)
{
return FindByCondition(owner => owner.Id.Equals(ownerId))
.FirstOrDefault();
}
public Owner GetOwnerWithDetails(Guid ownerId)
{
return FindByCondition(owner => owner.Id.Equals(ownerId))
.Include(ac => ac.Accounts)
.FirstOrDefault();
}
}
}
================================================
FILE: Part 5/AccountOwnerServer/Repository/Repository.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 5/AccountOwnerServer/Repository/RepositoryBase.cs
================================================
using Contracts;
using Entities;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;
namespace Repository
{
public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : class
{
protected RepositoryContext RepositoryContext { get; set; }
public RepositoryBase(RepositoryContext repositoryContext)
{
RepositoryContext = repositoryContext;
}
public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTracking();
public IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression) =>
RepositoryContext.Set<T>().Where(expression).AsNoTracking();
public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
public void Update(T entity) => RepositoryContext.Set<T>().Update(entity);
public void Delete(T entity) => RepositoryContext.Set<T>().Remove(entity);
}
}
================================================
FILE: Part 5/AccountOwnerServer/Repository/RepositoryWrapper.cs
================================================
using Contracts;
using Entities;
namespace Repository
{
public class RepositoryWrapper : IRepositoryWrapper
{
private RepositoryContext _repoContext;
private IOwnerRepository _owner;
private IAccountRepository _account;
public IOwnerRepository Owner
{
get
{
if (_owner == null)
{
_owner = new OwnerRepository(_repoContext);
}
return _owner;
}
}
public IAccountRepository Account
{
get
{
if (_account == null)
{
_account = new AccountRepository(_repoContext);
}
return _account;
}
}
public RepositoryWrapper(RepositoryContext repositoryContext)
{
_repoContext = repositoryContext;
}
public void Save()
{
_repoContext.SaveChanges();
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LoggerService\LoggerService.csproj" />
<ProjectReference Include="..\Repository\Repository.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs
================================================
using AutoMapper;
using Contracts;
using Entities.DataTransferObjects;
using Entities.Models;
using Microsoft.AspNetCore.Mvc;
namespace AccountOwnerServer.Controllers
{
[Route("api/owner")]
[ApiController]
public class OwnerController : ControllerBase
{
private ILoggerManager _logger;
private IRepositoryWrapper _repository;
private IMapper _mapper;
public OwnerController(ILoggerManager logger, IRepositoryWrapper repository, IMapper mapper)
{
_logger = logger;
_repository = repository;
_mapper = mapper;
}
[HttpGet]
public IActionResult GetAllOwners()
{
try
{
var owners = _repository.Owner.GetAllOwners();
_logger.LogInfo($"Returned all owners from database.");
var ownersResult = _mapper.Map<IEnumerable<OwnerDto>>(owners);
return Ok(ownersResult);
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetAllOwners action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpGet("{id}", Name = "OwnerById")]
public IActionResult GetOwnerById(Guid id)
{
try
{
var owner = _repository.Owner.GetOwnerById(id);
if (owner is null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
else
{
_logger.LogInfo($"Returned owner with id: {id}");
var ownerResult = _mapper.Map<OwnerDto>(owner);
return Ok(ownerResult);
}
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetOwnerById action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpGet("{id}/account")]
public IActionResult GetOwnerWithDetails(Guid id)
{
try
{
var owner = _repository.Owner.GetOwnerWithDetails(id);
if (owner == null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
else
{
_logger.LogInfo($"Returned owner with details for id: {id}");
var ownerResult = _mapper.Map<OwnerDto>(owner);
return Ok(ownerResult);
}
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside GetOwnerWithDetails action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpPost]
public IActionResult CreateOwner([FromBody] OwnerForCreationDto owner)
{
try
{
if (owner is null)
{
_logger.LogError("Owner object sent from client is null.");
return BadRequest("Owner object is null");
}
if (!ModelState.IsValid)
{
_logger.LogError("Invalid owner object sent from client.");
return BadRequest("Invalid model object");
}
var ownerEntity = _mapper.Map<Owner>(owner);
_repository.Owner.CreateOwner(ownerEntity);
_repository.Save();
var createdOwner = _mapper.Map<OwnerDto>(ownerEntity);
return CreatedAtRoute("OwnerById", new { id = createdOwner.Id }, createdOwner);
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside CreateOwner action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpPut("{id}")]
public IActionResult UpdateOwner(Guid id, [FromBody] OwnerForUpdateDto owner)
{
try
{
if (owner is null)
{
_logger.LogError("Owner object sent from client is null.");
return BadRequest("Owner object is null");
}
if (!ModelState.IsValid)
{
_logger.LogError("Invalid owner object sent from client.");
return BadRequest("Invalid model object");
}
var ownerEntity = _repository.Owner.GetOwnerById(id);
if (ownerEntity is null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
_mapper.Map(owner, ownerEntity);
_repository.Owner.UpdateOwner(ownerEntity);
_repository.Save();
return NoContent();
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside UpdateOwner action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
[HttpDelete("{id}")]
public IActionResult DeleteOwner(Guid id)
{
try
{
var owner = _repository.Owner.GetOwnerById(id);
if (owner == null)
{
_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
return NotFound();
}
if (_repository.Account.AccountsByOwner(id).Any())
{
_logger.LogError($"Cannot delete owner with id: {id}. It has related accounts. Delete those accounts first");
return BadRequest("Cannot delete owner. It has related accounts. Delete those accounts first");
}
_repository.Owner.DeleteOwner(owner);
_repository.Save();
return NoContent();
}
catch (Exception ex)
{
_logger.LogError($"Something went wrong inside DeleteOwner action: {ex.Message}");
return StatusCode(500, "Internal server error");
}
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
================================================
using Contracts;
using LoggerService;
using Microsoft.EntityFrameworkCore;
using Entities;
using Repository;
namespace AccountOwnerServer.Extensions
{
public static class ServiceExtensions
{
public static void ConfigureCors(this IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public static void ConfigureIISIntegration(this IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
}
public static void ConfigureLoggerService(this IServiceCollection services)
{
services.AddSingleton<ILoggerManager, LoggerManager>();
}
public static void ConfigureMySqlContext(this IServiceCollection services, IConfiguration config)
{
var connectionString = config["mysqlconnection:connectionString"];
services.AddDbContext<RepositoryContext>(o => o.UseMySql(connectionString,
MySqlServerVersion.LatestSupportedServerVersion));
}
public static void ConfigureRepositoryWrapper(this IServiceCollection services)
{
services.AddScoped<IRepositoryWrapper, RepositoryWrapper>();
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs
================================================
using AutoMapper;
using Entities.DataTransferObjects;
using Entities.Models;
using System.Linq;
namespace AccountOwnerServer
{
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Owner, OwnerDto>();
CreateMap<Account, AccountDto>();
CreateMap<OwnerForCreationDto, Owner>();
CreateMap<OwnerForUpdateDto, Owner>();
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Program.cs
================================================
using AccountOwnerServer.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using NLog;
var builder = WebApplication.CreateBuilder(args);
LogManager.Setup().LoadConfigurationFromFile(string.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
builder.Services.ConfigureCors();
builder.Services.ConfigureIISIntegration();
builder.Services.ConfigureLoggerService();
builder.Services.ConfigureMySqlContext(builder.Configuration);
builder.Services.ConfigureRepositoryWrapper();
builder.Services.AddAutoMapper(typeof(Program));
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseHsts();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.All
});
app.UseCors("CorsPolicy");
app.UseAuthorization();
app.MapControllers();
app.Run();
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json
================================================
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40700",
"sslPort": 44360
}
},
"profiles": {
"AccountOwnerServer": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/appsettings.json
================================================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"mysqlconnection": {
"connectionString": "server=localhost;userid=root;password=yourpass;database=accountowner;"
},
"AllowedHosts": "*"
}
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/nlog.config
================================================
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="d:Projects\Blog-AccountOwner\Project\internal_logs\internallog.txt">
<targets>
<target name="logfile" xsi:type="File"
fileName="d:/Projects/Blog-AccountOwner/Project/logs/${shortdate}_logfile.txt"
layout="${longdate} ${level:uppercase=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
================================================
FILE: Part 6/AccountOwnerServer/AccountOwnerServer.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountOwnerServer", "AccountOwnerServer\AccountOwnerServer.csproj", "{0213FB50-5C53-4C34-8B2C-E515C7DC2579}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{B731D3C2-9A89-40E4-B96B-AA300B4195BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoggerService", "LoggerService\LoggerService.csproj", "{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{16AAE663-A20E-493D-9087-F4F4016F6216}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0213FB50-5C53-4C34-8B2C-E515C7DC2579}.Release|Any CPU.Build.0 = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B731D3C2-9A89-40E4-B96B-AA300B4195BB}.Release|Any CPU.Build.0 = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CEC76F5-80AF-4B37-B6F1-94A743E5C748}.Release|Any CPU.Build.0 = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16AAE663-A20E-493D-9087-F4F4016F6216}.Release|Any CPU.Build.0 = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0C0D726-5224-4B8F-8C05-BB2C12A78D9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8E1F895-37AB-455B-8D05-ED495BE48F88}
EndGlobalSection
EndGlobal
================================================
FILE: Part 6/AccountOwnerServer/Contracts/Contracts.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 6/AccountOwnerServer/Contracts/IAccountRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IAccountRepository
{
IEnumerable<Account> AccountsByOwner(Guid ownerId);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Contracts/ILoggerManager.cs
================================================
namespace Contracts
{
public interface ILoggerManager
{
void LogInfo(string message);
void LogWarn(string message);
void LogDebug(string message);
void LogError(string message);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Contracts/IOwnerRepository.cs
================================================
using Entities.Models;
namespace Contracts
{
public interface IOwnerRepository
{
IEnumerable<Owner> GetAllOwners();
Owner GetOwnerById(Guid ownerId);
Owner GetOwnerWithDetails(Guid ownerId);
void CreateOwner(Owner owner);
void UpdateOwner(Owner owner);
void DeleteOwner(Owner owner);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Contracts/IRepositoryBase.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Contracts
{
public interface IRepositoryBase<T>
{
IQueryable<T> FindAll();
IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
void Create(T entity);
void Update(T entity);
void Delete(T entity);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace Contracts
{
public interface IRepositoryWrapper
{
IOwnerRepository Owner { get; }
IAccountRepository Account { get; }
void Save();
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs
================================================
using System;
namespace Entities.DataTransferObjects
{
public class AccountDto
{
public Guid Id { get; set; }
public DateTime DateCreated { get; set; }
public string? AccountType { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs
================================================
namespace Entities.DataTransferObjects
{
public class OwnerDto
{
public Guid Id { get; set; }
public string? Name { get; set; }
public DateTime DateOfBirth { get; set; }
public string? Address { get; set; }
public IEnumerable<AccountDto>? Accounts { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForCreationDto.cs
================================================
using System;
using System.ComponentModel.DataAnnotations;
namespace Entities.DataTransferObjects
{
public class OwnerForCreationDto
{
[Required(ErrorMessage = "Name is required")]
[StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]
public string? Name { get; set; }
[Required(ErrorMessage = "Date of birth is required")]
public DateTime DateOfBirth { get; set; }
[Required(ErrorMessage = "Address is required")]
[StringLength(100, ErrorMessage = "Address cannot be loner then 100 characters")]
public string? Address { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForUpdateDto.cs
================================================
using System;
using System.ComponentModel.DataAnnotations;
namespace Entities.DataTransferObjects
{
public class OwnerForUpdateDto
{
[Required(ErrorMessage = "Name is required")]
[StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]
public string Name { get; set; }
[Required(ErrorMessage = "Date of birth is required")]
public DateTime DateOfBirth { get; set; }
[Required(ErrorMessage = "Address is required")]
[StringLength(100, ErrorMessage = "Address cannot be loner then 100 characters")]
public string Address { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/Entities.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
</ItemGroup>
</Project>
================================================
FILE: Part 6/AccountOwnerServer/Entities/Models/Account.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("account")]
public class Account
{
[Column("AccountId")]
public Guid Id { get; set; }
[Required(ErrorMessage = "Date created is required")]
public DateTime DateCreated { get; set; }
[Required(ErrorMessage = "Account type is required")]
public string? AccountType { get; set; }
[ForeignKey(nameof(Owner))]
public Guid OwnerId { get; set; }
public Owner? Owner { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/Models/Owner.cs
================================================
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities.Models
{
[Table("owner")]
public class Owner
{
[Column("OwnerId")]
public Guid Id { get; set; }
[Required(ErrorMessage = "Name is required")]
[StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]
public string? Name { get; set; }
[Required(ErrorMessage = "Date of birth is required")]
public DateTime DateOfBirth { get; set; }
[Required(ErrorMessage = "Address is required")]
[StringLength(100, ErrorMessage = "Address cannot be loner then 100 characters")]
public string? Address { get; set; }
public ICollection<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/Entities/RepositoryContext.cs
================================================
using Entities.Models;
using Microsoft.EntityFrameworkCore;
namespace Entities
{
public class RepositoryContext : DbContext
{
public RepositoryContext(DbContextOptions options)
: base(options)
{
}
public DbSet<Owner>? Owners { get; set; }
public DbSet<Account>? Accounts { get; set; }
}
}
================================================
FILE: Part 6/AccountOwnerServer/LoggerService/LoggerManager.cs
================================================
using Contracts;
using NLog;
namespace LoggerService
{
public class LoggerManager : ILoggerManager
{
private static ILogger logger = LogManager.GetCurrentClassLogger();
public void LogDebug(string message) => logger.Debug(message);
public void LogError(string message) => logger.Error(message);
public void LogInfo(string message) => logger.Info(message);
public void LogWarn(string message) => logger.Warn(message);
}
}
================================================
FILE: Part 6/AccountOwnerServer/LoggerService/LoggerService.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 6/AccountOwnerServer/Repository/AccountRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
namespace Repository
{
public class AccountRepository : RepositoryBase<Account>, IAccountRepository
{
public AccountRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
public IEnumerable<Account> AccountsByOwner(Guid ownerId) =>
FindByCondition(a => a.OwnerId.Equals(ownerId)).ToList();
}
}
================================================
FILE: Part 6/AccountOwnerServer/Repository/OwnerRepository.cs
================================================
using Contracts;
using Entities;
using Entities.Models;
using Microsoft.EntityFrameworkCore;
namespace Repository
{
public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
{
public OwnerRepository(RepositoryContext repositoryContext)
: base(repositoryContext)
{
}
public IEnumerable<Owner> GetAllOwners()
{
return FindAll()
.OrderBy(ow => ow.Name)
.ToList();
}
public Owner GetOwnerById(Guid ownerId)
{
return FindByCondition(owner => owner.Id.Equals(ownerId))
.FirstOrDefault();
}
public Owner GetOwnerWithDetails(Guid ownerId)
{
return FindByCondition(owner => owner.Id.Equals(ownerId))
.Include(ac => ac.Accounts)
.FirstOrDefault();
}
public void CreateOwner(Owner owner) => Create(owner);
public void UpdateOwner(Owner owner) => Update(owner);
public void DeleteOwner(Owner owner) => Delete(owner);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Repository/Repository.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>
================================================
FILE: Part 6/AccountOwnerServer/Repository/RepositoryBase.cs
================================================
using Contracts;
using Entities;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;
namespace Repository
{
public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : class
{
protected RepositoryContext RepositoryContext { get; set; }
public RepositoryBase(RepositoryContext repositoryContext)
{
RepositoryContext = repositoryContext;
}
public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTracking();
public IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression) =>
RepositoryContext.Set<T>().Where(expression).AsNoTracking();
public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
public void Update(T entity) => RepositoryContext.Set<T>().Update(entity);
public void Delete(T entity) => RepositoryContext.Set<T>().Remove(entity);
}
}
================================================
FILE: Part 6/AccountOwnerServer/Repository/RepositoryWrapper.cs
================================================
using Contracts;
using Entities;
namespace Repository
{
public class RepositoryWrapper : IRepositoryWrapper
{
private RepositoryContext _repoContext;
private IOwnerRepository _owner;
private IAccountRepository _account;
public IOwnerRepository Owner
{
get
{
if (_owner == null)
{
_owner = new OwnerRepository(_repoContext);
}
return _owner;
}
}
public IAccountRepository Account
{
get
{
if (_account == null)
{
_account = new AccountRepository(_repoContext);
}
return _account;
}
}
public RepositoryWrapper(RepositoryContext repositoryContext)
{
_repoContext = repositoryContext;
}
public void Save()
{
_repoContext.SaveChanges();
}
}
}
================================================
FILE: README.md
================================================
# .NET-Core-Series
Code Maze .NET Core Series
https://code-maze.com/net-core-series/
gitextract_2hk3m77t/ ├── .gitignore ├── Part 1/ │ ├── Schema.mwb │ ├── Schema.mwb.bak │ └── init.sql ├── Part 2/ │ └── AccountOwnerServer/ │ ├── AccountOwnerServer/ │ │ ├── AccountOwnerServer.csproj │ │ ├── Controllers/ │ │ │ └── WeatherForecastController.cs │ │ ├── Extensions/ │ │ │ └── ServiceExtensions.cs │ │ ├── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ └── AccountOwnerServer.sln ├── Part 3/ │ └── AccountOwnerServer/ │ ├── AccountOwnerServer/ │ │ ├── AccountOwnerServer.csproj │ │ ├── Controllers/ │ │ │ └── WeatherForecastController.cs │ │ ├── Extensions/ │ │ │ └── ServiceExtensions.cs │ │ ├── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── nlog.config │ ├── AccountOwnerServer.sln │ ├── Contracts/ │ │ ├── Contracts.csproj │ │ └── ILoggerManager.cs │ └── LoggerService/ │ ├── LoggerManager.cs │ └── LoggerService.csproj ├── Part 4/ │ └── AccountOwnerServer/ │ ├── AccountOwnerServer/ │ │ ├── AccountOwnerServer.csproj │ │ ├── Controllers/ │ │ │ └── WeatherForecastController.cs │ │ ├── Extensions/ │ │ │ └── ServiceExtensions.cs │ │ ├── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── nlog.config │ ├── AccountOwnerServer.sln │ ├── Contracts/ │ │ ├── Contracts.csproj │ │ ├── IAccountRepository.cs │ │ ├── ILoggerManager.cs │ │ ├── IOwnerRepository.cs │ │ ├── IRepositoryBase.cs │ │ └── IRepositoryWrapper.cs │ ├── Entities/ │ │ ├── Entities.csproj │ │ ├── Models/ │ │ │ ├── Account.cs │ │ │ └── Owner.cs │ │ └── RepositoryContext.cs │ ├── LoggerService/ │ │ ├── LoggerManager.cs │ │ └── LoggerService.csproj │ └── Repository/ │ ├── AccountRepository.cs │ ├── OwnerRepository.cs │ ├── Repository.csproj │ ├── RepositoryBase.cs │ └── RepositoryWrapper.cs ├── Part 5/ │ └── AccountOwnerServer/ │ ├── AccountOwnerServer/ │ │ ├── AccountOwnerServer.csproj │ │ ├── Controllers/ │ │ │ └── OwnerController.cs │ │ ├── Extensions/ │ │ │ └── ServiceExtensions.cs │ │ ├── MappingProfile.cs │ │ ├── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── nlog.config │ ├── AccountOwnerServer.sln │ ├── Contracts/ │ │ ├── Contracts.csproj │ │ ├── IAccountRepository.cs │ │ ├── ILoggerManager.cs │ │ ├── IOwnerRepository.cs │ │ ├── IRepositoryBase.cs │ │ └── IRepositoryWrapper.cs │ ├── Entities/ │ │ ├── DataTransferObjects/ │ │ │ ├── AccountDto.cs │ │ │ └── OwnerDto.cs │ │ ├── Entities.csproj │ │ ├── Models/ │ │ │ ├── Account.cs │ │ │ └── Owner.cs │ │ └── RepositoryContext.cs │ ├── LoggerService/ │ │ ├── LoggerManager.cs │ │ └── LoggerService.csproj │ └── Repository/ │ ├── AccountRepository.cs │ ├── OwnerRepository.cs │ ├── Repository.csproj │ ├── RepositoryBase.cs │ └── RepositoryWrapper.cs ├── Part 6/ │ └── AccountOwnerServer/ │ ├── AccountOwnerServer/ │ │ ├── AccountOwnerServer.csproj │ │ ├── Controllers/ │ │ │ └── OwnerController.cs │ │ ├── Extensions/ │ │ │ └── ServiceExtensions.cs │ │ ├── MappingProfile.cs │ │ ├── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── nlog.config │ ├── AccountOwnerServer.sln │ ├── Contracts/ │ │ ├── Contracts.csproj │ │ ├── IAccountRepository.cs │ │ ├── ILoggerManager.cs │ │ ├── IOwnerRepository.cs │ │ ├── IRepositoryBase.cs │ │ └── IRepositoryWrapper.cs │ ├── Entities/ │ │ ├── DataTransferObjects/ │ │ │ ├── AccountDto.cs │ │ │ ├── OwnerDto.cs │ │ │ ├── OwnerForCreationDto.cs │ │ │ └── OwnerForUpdateDto.cs │ │ ├── Entities.csproj │ │ ├── Models/ │ │ │ ├── Account.cs │ │ │ └── Owner.cs │ │ └── RepositoryContext.cs │ ├── LoggerService/ │ │ ├── LoggerManager.cs │ │ └── LoggerService.csproj │ └── Repository/ │ ├── AccountRepository.cs │ ├── OwnerRepository.cs │ ├── Repository.csproj │ ├── RepositoryBase.cs │ └── RepositoryWrapper.cs └── README.md
SYMBOL INDEX (206 symbols across 63 files)
FILE: Part 1/init.sql
type `AccountOwner` (line 25) | CREATE TABLE IF NOT EXISTS `AccountOwner`.`Owner` (
type `AccountOwner` (line 39) | CREATE TABLE IF NOT EXISTS `AccountOwner`.`Account` (
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
class WeatherForecastController (line 5) | [ApiController]
method WeatherForecastController (line 16) | public WeatherForecastController(ILogger<WeatherForecastController> lo...
method Get (line 21) | [HttpGet]
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
class ServiceExtensions (line 3) | public static class ServiceExtensions
method ConfigureCors (line 5) | public static void ConfigureCors(this IServiceCollection services)
method ConfigureIISIntegration (line 16) | public static void ConfigureIISIntegration(this IServiceCollection ser...
FILE: Part 2/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
class WeatherForecastController (line 6) | [ApiController]
method WeatherForecastController (line 12) | public WeatherForecastController(ILoggerManager logger)
method Get (line 17) | [HttpGet]
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
class ServiceExtensions (line 6) | public static class ServiceExtensions
method ConfigureCors (line 8) | public static void ConfigureCors(this IServiceCollection services)
method ConfigureIISIntegration (line 19) | public static void ConfigureIISIntegration(this IServiceCollection ser...
method ConfigureLoggerService (line 27) | public static void ConfigureLoggerService(this IServiceCollection serv...
FILE: Part 3/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
FILE: Part 3/AccountOwnerServer/Contracts/ILoggerManager.cs
type ILoggerManager (line 3) | public interface ILoggerManager
method LogInfo (line 5) | void LogInfo(string message);
method LogWarn (line 6) | void LogWarn(string message);
method LogDebug (line 7) | void LogDebug(string message);
method LogError (line 8) | void LogError(string message);
FILE: Part 3/AccountOwnerServer/LoggerService/LoggerManager.cs
class LoggerManager (line 6) | public class LoggerManager : ILoggerManager
method LogDebug (line 10) | public void LogDebug(string message) => logger.Debug(message);
method LogError (line 12) | public void LogError(string message) => logger.Error(message);
method LogInfo (line 14) | public void LogInfo(string message) => logger.Info(message);
method LogWarn (line 16) | public void LogWarn(string message) => logger.Warn(message);
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs
class WeatherForecastController (line 6) | [ApiController]
method WeatherForecastController (line 12) | public WeatherForecastController(IRepositoryWrapper repository)
method Get (line 17) | [HttpGet]
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
class ServiceExtensions (line 9) | public static class ServiceExtensions
method ConfigureCors (line 11) | public static void ConfigureCors(this IServiceCollection services)
method ConfigureIISIntegration (line 22) | public static void ConfigureIISIntegration(this IServiceCollection ser...
method ConfigureLoggerService (line 30) | public static void ConfigureLoggerService(this IServiceCollection serv...
method ConfigureMySqlContext (line 35) | public static void ConfigureMySqlContext(this IServiceCollection servi...
method ConfigureRepositoryWrapper (line 43) | public static void ConfigureRepositoryWrapper(this IServiceCollection ...
FILE: Part 4/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs
class WeatherForecast (line 3) | public class WeatherForecast
FILE: Part 4/AccountOwnerServer/Contracts/IAccountRepository.cs
type IAccountRepository (line 5) | public interface IAccountRepository : IRepositoryBase<Account>
FILE: Part 4/AccountOwnerServer/Contracts/ILoggerManager.cs
type ILoggerManager (line 3) | public interface ILoggerManager
method LogInfo (line 5) | void LogInfo(string message);
method LogWarn (line 6) | void LogWarn(string message);
method LogDebug (line 7) | void LogDebug(string message);
method LogError (line 8) | void LogError(string message);
FILE: Part 4/AccountOwnerServer/Contracts/IOwnerRepository.cs
type IOwnerRepository (line 5) | public interface IOwnerRepository : IRepositoryBase<Owner>
FILE: Part 4/AccountOwnerServer/Contracts/IRepositoryBase.cs
type IRepositoryBase (line 9) | public interface IRepositoryBase<T>
method FindAll (line 11) | IQueryable<T> FindAll();
method FindByCondition (line 12) | IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
method Create (line 13) | void Create(T entity);
method Update (line 14) | void Update(T entity);
method Delete (line 15) | void Delete(T entity);
FILE: Part 4/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
type IRepositoryWrapper (line 7) | public interface IRepositoryWrapper
method Save (line 11) | void Save();
FILE: Part 4/AccountOwnerServer/Entities/Models/Account.cs
class Account (line 6) | [Table("account")]
FILE: Part 4/AccountOwnerServer/Entities/Models/Owner.cs
class Owner (line 6) | [Table("owner")]
FILE: Part 4/AccountOwnerServer/Entities/RepositoryContext.cs
class RepositoryContext (line 6) | public class RepositoryContext : DbContext
method RepositoryContext (line 8) | public RepositoryContext(DbContextOptions options)
FILE: Part 4/AccountOwnerServer/LoggerService/LoggerManager.cs
class LoggerManager (line 6) | public class LoggerManager : ILoggerManager
method LogDebug (line 10) | public void LogDebug(string message) => logger.Debug(message);
method LogError (line 12) | public void LogError(string message) => logger.Error(message);
method LogInfo (line 14) | public void LogInfo(string message) => logger.Info(message);
method LogWarn (line 16) | public void LogWarn(string message) => logger.Warn(message);
FILE: Part 4/AccountOwnerServer/Repository/AccountRepository.cs
class AccountRepository (line 7) | public class AccountRepository : RepositoryBase<Account>, IAccountReposi...
method AccountRepository (line 9) | public AccountRepository(RepositoryContext repositoryContext)
FILE: Part 4/AccountOwnerServer/Repository/OwnerRepository.cs
class OwnerRepository (line 7) | public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
method OwnerRepository (line 9) | public OwnerRepository(RepositoryContext repositoryContext)
FILE: Part 4/AccountOwnerServer/Repository/RepositoryBase.cs
class RepositoryBase (line 8) | public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : c...
method RepositoryBase (line 11) | public RepositoryBase(RepositoryContext repositoryContext)
method FindAll (line 16) | public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTrack...
method FindByCondition (line 18) | public IQueryable<T> FindByCondition(Expression<Func<T, bool>> express...
method Create (line 21) | public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
method Update (line 23) | public void Update(T entity) => RepositoryContext.Set<T>().Update(enti...
method Delete (line 25) | public void Delete(T entity) => RepositoryContext.Set<T>().Remove(enti...
FILE: Part 4/AccountOwnerServer/Repository/RepositoryWrapper.cs
class RepositoryWrapper (line 6) | public class RepositoryWrapper : IRepositoryWrapper
method RepositoryWrapper (line 35) | public RepositoryWrapper(RepositoryContext repositoryContext)
method Save (line 40) | public void Save()
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs
class OwnerController (line 8) | [Route("api/owner")]
method OwnerController (line 16) | public OwnerController(ILoggerManager logger, IRepositoryWrapper repos...
method GetAllOwners (line 23) | [HttpGet]
method GetOwnerById (line 42) | [HttpGet("{id}")]
method GetOwnerWithDetails (line 68) | [HttpGet("{id}/account")]
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
class ServiceExtensions (line 9) | public static class ServiceExtensions
method ConfigureCors (line 11) | public static void ConfigureCors(this IServiceCollection services)
method ConfigureIISIntegration (line 22) | public static void ConfigureIISIntegration(this IServiceCollection ser...
method ConfigureLoggerService (line 30) | public static void ConfigureLoggerService(this IServiceCollection serv...
method ConfigureMySqlContext (line 35) | public static void ConfigureMySqlContext(this IServiceCollection servi...
method ConfigureRepositoryWrapper (line 43) | public static void ConfigureRepositoryWrapper(this IServiceCollection ...
FILE: Part 5/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs
class MappingProfile (line 8) | public class MappingProfile : Profile
method MappingProfile (line 10) | public MappingProfile()
FILE: Part 5/AccountOwnerServer/Contracts/IAccountRepository.cs
type IAccountRepository (line 5) | public interface IAccountRepository
FILE: Part 5/AccountOwnerServer/Contracts/ILoggerManager.cs
type ILoggerManager (line 3) | public interface ILoggerManager
method LogInfo (line 5) | void LogInfo(string message);
method LogWarn (line 6) | void LogWarn(string message);
method LogDebug (line 7) | void LogDebug(string message);
method LogError (line 8) | void LogError(string message);
FILE: Part 5/AccountOwnerServer/Contracts/IOwnerRepository.cs
type IOwnerRepository (line 5) | public interface IOwnerRepository
method GetAllOwners (line 7) | IEnumerable<Owner> GetAllOwners();
method GetOwnerById (line 8) | Owner GetOwnerById(Guid ownerId);
method GetOwnerWithDetails (line 9) | Owner GetOwnerWithDetails(Guid ownerId);
FILE: Part 5/AccountOwnerServer/Contracts/IRepositoryBase.cs
type IRepositoryBase (line 9) | public interface IRepositoryBase<T>
method FindAll (line 11) | IQueryable<T> FindAll();
method FindByCondition (line 12) | IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
method Create (line 13) | void Create(T entity);
method Update (line 14) | void Update(T entity);
method Delete (line 15) | void Delete(T entity);
FILE: Part 5/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
type IRepositoryWrapper (line 7) | public interface IRepositoryWrapper
method Save (line 11) | void Save();
FILE: Part 5/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs
class AccountDto (line 5) | public class AccountDto
FILE: Part 5/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs
class OwnerDto (line 3) | public class OwnerDto
FILE: Part 5/AccountOwnerServer/Entities/Models/Account.cs
class Account (line 6) | [Table("account")]
FILE: Part 5/AccountOwnerServer/Entities/Models/Owner.cs
class Owner (line 6) | [Table("owner")]
FILE: Part 5/AccountOwnerServer/Entities/RepositoryContext.cs
class RepositoryContext (line 6) | public class RepositoryContext : DbContext
method RepositoryContext (line 8) | public RepositoryContext(DbContextOptions options)
FILE: Part 5/AccountOwnerServer/LoggerService/LoggerManager.cs
class LoggerManager (line 6) | public class LoggerManager : ILoggerManager
method LogDebug (line 10) | public void LogDebug(string message) => logger.Debug(message);
method LogError (line 12) | public void LogError(string message) => logger.Error(message);
method LogInfo (line 14) | public void LogInfo(string message) => logger.Info(message);
method LogWarn (line 16) | public void LogWarn(string message) => logger.Warn(message);
FILE: Part 5/AccountOwnerServer/Repository/AccountRepository.cs
class AccountRepository (line 7) | public class AccountRepository : RepositoryBase<Account>, IAccountReposi...
method AccountRepository (line 9) | public AccountRepository(RepositoryContext repositoryContext)
FILE: Part 5/AccountOwnerServer/Repository/OwnerRepository.cs
class OwnerRepository (line 8) | public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
method OwnerRepository (line 10) | public OwnerRepository(RepositoryContext repositoryContext)
method GetAllOwners (line 15) | public IEnumerable<Owner> GetAllOwners()
method GetOwnerById (line 22) | public Owner GetOwnerById(Guid ownerId)
method GetOwnerWithDetails (line 28) | public Owner GetOwnerWithDetails(Guid ownerId)
FILE: Part 5/AccountOwnerServer/Repository/RepositoryBase.cs
class RepositoryBase (line 8) | public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : c...
method RepositoryBase (line 11) | public RepositoryBase(RepositoryContext repositoryContext)
method FindAll (line 16) | public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTrack...
method FindByCondition (line 18) | public IQueryable<T> FindByCondition(Expression<Func<T, bool>> express...
method Create (line 21) | public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
method Update (line 23) | public void Update(T entity) => RepositoryContext.Set<T>().Update(enti...
method Delete (line 25) | public void Delete(T entity) => RepositoryContext.Set<T>().Remove(enti...
FILE: Part 5/AccountOwnerServer/Repository/RepositoryWrapper.cs
class RepositoryWrapper (line 6) | public class RepositoryWrapper : IRepositoryWrapper
method RepositoryWrapper (line 35) | public RepositoryWrapper(RepositoryContext repositoryContext)
method Save (line 40) | public void Save()
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs
class OwnerController (line 9) | [Route("api/owner")]
method OwnerController (line 17) | public OwnerController(ILoggerManager logger, IRepositoryWrapper repos...
method GetAllOwners (line 24) | [HttpGet]
method GetOwnerById (line 43) | [HttpGet("{id}", Name = "OwnerById")]
method GetOwnerWithDetails (line 69) | [HttpGet("{id}/account")]
method CreateOwner (line 95) | [HttpPost]
method UpdateOwner (line 128) | [HttpPut("{id}")]
method DeleteOwner (line 166) | [HttpDelete("{id}")]
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs
class ServiceExtensions (line 9) | public static class ServiceExtensions
method ConfigureCors (line 11) | public static void ConfigureCors(this IServiceCollection services)
method ConfigureIISIntegration (line 22) | public static void ConfigureIISIntegration(this IServiceCollection ser...
method ConfigureLoggerService (line 30) | public static void ConfigureLoggerService(this IServiceCollection serv...
method ConfigureMySqlContext (line 35) | public static void ConfigureMySqlContext(this IServiceCollection servi...
method ConfigureRepositoryWrapper (line 43) | public static void ConfigureRepositoryWrapper(this IServiceCollection ...
FILE: Part 6/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs
class MappingProfile (line 8) | public class MappingProfile : Profile
method MappingProfile (line 10) | public MappingProfile()
FILE: Part 6/AccountOwnerServer/Contracts/IAccountRepository.cs
type IAccountRepository (line 5) | public interface IAccountRepository
method AccountsByOwner (line 7) | IEnumerable<Account> AccountsByOwner(Guid ownerId);
FILE: Part 6/AccountOwnerServer/Contracts/ILoggerManager.cs
type ILoggerManager (line 3) | public interface ILoggerManager
method LogInfo (line 5) | void LogInfo(string message);
method LogWarn (line 6) | void LogWarn(string message);
method LogDebug (line 7) | void LogDebug(string message);
method LogError (line 8) | void LogError(string message);
FILE: Part 6/AccountOwnerServer/Contracts/IOwnerRepository.cs
type IOwnerRepository (line 5) | public interface IOwnerRepository
method GetAllOwners (line 7) | IEnumerable<Owner> GetAllOwners();
method GetOwnerById (line 8) | Owner GetOwnerById(Guid ownerId);
method GetOwnerWithDetails (line 9) | Owner GetOwnerWithDetails(Guid ownerId);
method CreateOwner (line 10) | void CreateOwner(Owner owner);
method UpdateOwner (line 11) | void UpdateOwner(Owner owner);
method DeleteOwner (line 12) | void DeleteOwner(Owner owner);
FILE: Part 6/AccountOwnerServer/Contracts/IRepositoryBase.cs
type IRepositoryBase (line 9) | public interface IRepositoryBase<T>
method FindAll (line 11) | IQueryable<T> FindAll();
method FindByCondition (line 12) | IQueryable<T> FindByCondition(Expression<Func<T, bool>> expression);
method Create (line 13) | void Create(T entity);
method Update (line 14) | void Update(T entity);
method Delete (line 15) | void Delete(T entity);
FILE: Part 6/AccountOwnerServer/Contracts/IRepositoryWrapper.cs
type IRepositoryWrapper (line 7) | public interface IRepositoryWrapper
method Save (line 11) | void Save();
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs
class AccountDto (line 5) | public class AccountDto
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs
class OwnerDto (line 3) | public class OwnerDto
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForCreationDto.cs
class OwnerForCreationDto (line 6) | public class OwnerForCreationDto
FILE: Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForUpdateDto.cs
class OwnerForUpdateDto (line 6) | public class OwnerForUpdateDto
FILE: Part 6/AccountOwnerServer/Entities/Models/Account.cs
class Account (line 6) | [Table("account")]
FILE: Part 6/AccountOwnerServer/Entities/Models/Owner.cs
class Owner (line 6) | [Table("owner")]
FILE: Part 6/AccountOwnerServer/Entities/RepositoryContext.cs
class RepositoryContext (line 6) | public class RepositoryContext : DbContext
method RepositoryContext (line 8) | public RepositoryContext(DbContextOptions options)
FILE: Part 6/AccountOwnerServer/LoggerService/LoggerManager.cs
class LoggerManager (line 6) | public class LoggerManager : ILoggerManager
method LogDebug (line 10) | public void LogDebug(string message) => logger.Debug(message);
method LogError (line 12) | public void LogError(string message) => logger.Error(message);
method LogInfo (line 14) | public void LogInfo(string message) => logger.Info(message);
method LogWarn (line 16) | public void LogWarn(string message) => logger.Warn(message);
FILE: Part 6/AccountOwnerServer/Repository/AccountRepository.cs
class AccountRepository (line 7) | public class AccountRepository : RepositoryBase<Account>, IAccountReposi...
method AccountRepository (line 9) | public AccountRepository(RepositoryContext repositoryContext)
method AccountsByOwner (line 14) | public IEnumerable<Account> AccountsByOwner(Guid ownerId) =>
FILE: Part 6/AccountOwnerServer/Repository/OwnerRepository.cs
class OwnerRepository (line 8) | public class OwnerRepository : RepositoryBase<Owner>, IOwnerRepository
method OwnerRepository (line 10) | public OwnerRepository(RepositoryContext repositoryContext)
method GetAllOwners (line 15) | public IEnumerable<Owner> GetAllOwners()
method GetOwnerById (line 22) | public Owner GetOwnerById(Guid ownerId)
method GetOwnerWithDetails (line 28) | public Owner GetOwnerWithDetails(Guid ownerId)
method CreateOwner (line 35) | public void CreateOwner(Owner owner) => Create(owner);
method UpdateOwner (line 37) | public void UpdateOwner(Owner owner) => Update(owner);
method DeleteOwner (line 39) | public void DeleteOwner(Owner owner) => Delete(owner);
FILE: Part 6/AccountOwnerServer/Repository/RepositoryBase.cs
class RepositoryBase (line 8) | public abstract class RepositoryBase<T> : IRepositoryBase<T> where T : c...
method RepositoryBase (line 11) | public RepositoryBase(RepositoryContext repositoryContext)
method FindAll (line 16) | public IQueryable<T> FindAll() => RepositoryContext.Set<T>().AsNoTrack...
method FindByCondition (line 18) | public IQueryable<T> FindByCondition(Expression<Func<T, bool>> express...
method Create (line 21) | public void Create(T entity) => RepositoryContext.Set<T>().Add(entity);
method Update (line 23) | public void Update(T entity) => RepositoryContext.Set<T>().Update(enti...
method Delete (line 25) | public void Delete(T entity) => RepositoryContext.Set<T>().Remove(enti...
FILE: Part 6/AccountOwnerServer/Repository/RepositoryWrapper.cs
class RepositoryWrapper (line 6) | public class RepositoryWrapper : IRepositoryWrapper
method RepositoryWrapper (line 35) | public RepositoryWrapper(RepositoryContext repositoryContext)
method Save (line 40) | public void Save()
Condensed preview — 115 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (92K chars).
[
{
"path": ".gitignore",
"chars": 796,
"preview": "/Part 3/.vs\n/Part 3/AccountOwnerServer/obj\n/Part 3/AccountOwnerServer/AccountOwnerServer.csproj.user\n/Part 3/AccountOwne"
},
{
"path": "Part 1/init.sql",
"chars": 1988,
"preview": "-- MySQL Script generated by MySQL Workbench\n-- Wed Jan 22 11:12:09 2025\n-- Model: New Model Version: 1.0\n-- MySQL Wo"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj",
"chars": 210,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <Nullable>ena"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs",
"chars": 991,
"preview": "using Microsoft.AspNetCore.Mvc;\n\nnamespace AccountOwnerServer.Controllers\n{\n [ApiController]\n [Route(\"[controller]"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs",
"chars": 637,
"preview": "namespace AccountOwnerServer.Extensions\n{\n public static class ServiceExtensions\n {\n public static void Co"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/Program.cs",
"chars": 697,
"preview": "using AccountOwnerServer.Extensions;\nusing Microsoft.AspNetCore.HttpOverrides;\n\nvar builder = WebApplication.CreateBuild"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json",
"chars": 809,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs",
"chars": 284,
"preview": "namespace AccountOwnerServer\n{\n public class WeatherForecast\n {\n public DateTime Date { get; set; }\n\n "
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer/appsettings.json",
"chars": 142,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "Part 2/AccountOwnerServer/AccountOwnerServer.sln",
"chars": 1133,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.1.3221"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj",
"chars": 313,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <Nullable>ena"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs",
"chars": 818,
"preview": "using Contracts;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace AccountOwnerServer.Controllers\n{\n [ApiController]\n [Ro"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs",
"chars": 851,
"preview": "using Contracts;\nusing LoggerService;\n\nnamespace AccountOwnerServer.Extensions\n{\n public static class ServiceExtensi"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/Program.cs",
"chars": 828,
"preview": "using AccountOwnerServer.Extensions;\nusing Microsoft.AspNetCore.HttpOverrides;\nusing NLog;\n\nvar builder = WebApplication"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json",
"chars": 809,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs",
"chars": 284,
"preview": "namespace AccountOwnerServer\n{\n public class WeatherForecast\n {\n public DateTime Date { get; set; }\n\n "
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/appsettings.json",
"chars": 142,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer/nlog.config",
"chars": 625,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\n xmlns:xsi=\"htt"
},
{
"path": "Part 3/AccountOwnerServer/AccountOwnerServer.sln",
"chars": 2095,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.1.3221"
},
{
"path": "Part 3/AccountOwnerServer/Contracts/Contracts.csproj",
"chars": 206,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 3/AccountOwnerServer/Contracts/ILoggerManager.cs",
"chars": 227,
"preview": "namespace Contracts\n{\n public interface ILoggerManager\n {\n void LogInfo(string message);\n void LogW"
},
{
"path": "Part 3/AccountOwnerServer/LoggerService/LoggerManager.cs",
"chars": 478,
"preview": "using Contracts;\nusing NLog;\n\nnamespace LoggerService\n{\n public class LoggerManager : ILoggerManager\n {\n p"
},
{
"path": "Part 3/AccountOwnerServer/LoggerService/LoggerService.csproj",
"chars": 407,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj",
"chars": 517,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <Nullable>ena"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/Controllers/WeatherForecastController.cs",
"chars": 695,
"preview": "using Contracts;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace AccountOwnerServer.Controllers\n{\n [ApiController]\n [Ro"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs",
"chars": 1469,
"preview": "using Contracts;\nusing LoggerService;\nusing Microsoft.EntityFrameworkCore;\nusing Entities;\nusing Repository;\n\nnamespace"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/Program.cs",
"chars": 938,
"preview": "using AccountOwnerServer.Extensions;\nusing Microsoft.AspNetCore.HttpOverrides;\nusing NLog;\n\nvar builder = WebApplication"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json",
"chars": 809,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/WeatherForecast.cs",
"chars": 284,
"preview": "namespace AccountOwnerServer\n{\n public class WeatherForecast\n {\n public DateTime Date { get; set; }\n\n "
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/appsettings.json",
"chars": 270,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer/nlog.config",
"chars": 625,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\n xmlns:xsi=\"htt"
},
{
"path": "Part 4/AccountOwnerServer/AccountOwnerServer.sln",
"chars": 3045,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.1.3221"
},
{
"path": "Part 4/AccountOwnerServer/Contracts/Contracts.csproj",
"chars": 299,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 4/AccountOwnerServer/Contracts/IAccountRepository.cs",
"chars": 128,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IAccountRepository : IRepositoryBase<Account>\n {\n"
},
{
"path": "Part 4/AccountOwnerServer/Contracts/ILoggerManager.cs",
"chars": 227,
"preview": "namespace Contracts\n{\n public interface ILoggerManager\n {\n void LogInfo(string message);\n void LogW"
},
{
"path": "Part 4/AccountOwnerServer/Contracts/IOwnerRepository.cs",
"chars": 124,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IOwnerRepository : IRepositoryBase<Owner>\n {\n "
},
{
"path": "Part 4/AccountOwnerServer/Contracts/IRepositoryBase.cs",
"chars": 402,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Text;\n\nn"
},
{
"path": "Part 4/AccountOwnerServer/Contracts/IRepositoryWrapper.cs",
"chars": 255,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Contracts\n{\n public interface IReposit"
},
{
"path": "Part 4/AccountOwnerServer/Entities/Entities.csproj",
"chars": 317,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 4/AccountOwnerServer/Entities/Models/Account.cs",
"chars": 583,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 4/AccountOwnerServer/Entities/Models/Owner.cs",
"chars": 785,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 4/AccountOwnerServer/Entities/RepositoryContext.cs",
"chars": 359,
"preview": "using Entities.Models;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Entities\n{\n public class RepositoryContext : "
},
{
"path": "Part 4/AccountOwnerServer/LoggerService/LoggerManager.cs",
"chars": 478,
"preview": "using Contracts;\nusing NLog;\n\nnamespace LoggerService\n{\n public class LoggerManager : ILoggerManager\n {\n p"
},
{
"path": "Part 4/AccountOwnerServer/LoggerService/LoggerService.csproj",
"chars": 407,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 4/AccountOwnerServer/Repository/AccountRepository.cs",
"chars": 310,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\n\nnamespace Repository\n{\n public class AccountRepository : Re"
},
{
"path": "Part 4/AccountOwnerServer/Repository/OwnerRepository.cs",
"chars": 302,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\n\nnamespace Repository\n{\n public class OwnerRepository : Repo"
},
{
"path": "Part 4/AccountOwnerServer/Repository/Repository.csproj",
"chars": 364,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 4/AccountOwnerServer/Repository/RepositoryBase.cs",
"chars": 926,
"preview": "using Contracts;\nusing Entities;\nusing Microsoft.EntityFrameworkCore;\nusing System.Linq.Expressions;\n\nnamespace Reposit"
},
{
"path": "Part 4/AccountOwnerServer/Repository/RepositoryWrapper.cs",
"chars": 1095,
"preview": "using Contracts;\nusing Entities;\n\nnamespace Repository\n{\n public class RepositoryWrapper : IRepositoryWrapper \n {"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj",
"chars": 580,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <Nullable>ena"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs",
"chars": 3031,
"preview": "using AutoMapper;\nusing Contracts;\nusing Entities.DataTransferObjects;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Accou"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs",
"chars": 1469,
"preview": "using Contracts;\nusing LoggerService;\nusing Microsoft.EntityFrameworkCore;\nusing Entities;\nusing Repository;\n\nnamespace"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs",
"chars": 326,
"preview": "using AutoMapper;\nusing Entities.DataTransferObjects;\nusing Entities.Models;\nusing System.Linq;\n\nnamespace AccountOwner"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/Program.cs",
"chars": 987,
"preview": "using AccountOwnerServer.Extensions;\nusing Microsoft.AspNetCore.HttpOverrides;\nusing NLog;\n\nvar builder = WebApplication"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json",
"chars": 809,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/appsettings.json",
"chars": 270,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer/nlog.config",
"chars": 625,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\n xmlns:xsi=\"htt"
},
{
"path": "Part 5/AccountOwnerServer/AccountOwnerServer.sln",
"chars": 3045,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.1.3221"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/Contracts.csproj",
"chars": 299,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/IAccountRepository.cs",
"chars": 101,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IAccountRepository\n {\n }\n}\n"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/ILoggerManager.cs",
"chars": 227,
"preview": "namespace Contracts\n{\n public interface ILoggerManager\n {\n void LogInfo(string message);\n void LogW"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/IOwnerRepository.cs",
"chars": 233,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IOwnerRepository\n {\n IEnumerable<Owner> Ge"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/IRepositoryBase.cs",
"chars": 402,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Text;\n\nn"
},
{
"path": "Part 5/AccountOwnerServer/Contracts/IRepositoryWrapper.cs",
"chars": 255,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Contracts\n{\n public interface IReposit"
},
{
"path": "Part 5/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs",
"chars": 235,
"preview": "using System;\n\nnamespace Entities.DataTransferObjects\n{\n public class AccountDto\n {\n public Guid Id { get;"
},
{
"path": "Part 5/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs",
"chars": 320,
"preview": "namespace Entities.DataTransferObjects\n{\n public class OwnerDto\n {\n public Guid Id { get; set; }\n p"
},
{
"path": "Part 5/AccountOwnerServer/Entities/Entities.csproj",
"chars": 317,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 5/AccountOwnerServer/Entities/Models/Account.cs",
"chars": 606,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 5/AccountOwnerServer/Entities/Models/Owner.cs",
"chars": 807,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 5/AccountOwnerServer/Entities/RepositoryContext.cs",
"chars": 359,
"preview": "using Entities.Models;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Entities\n{\n public class RepositoryContext : "
},
{
"path": "Part 5/AccountOwnerServer/LoggerService/LoggerManager.cs",
"chars": 478,
"preview": "using Contracts;\nusing NLog;\n\nnamespace LoggerService\n{\n public class LoggerManager : ILoggerManager\n {\n p"
},
{
"path": "Part 5/AccountOwnerServer/LoggerService/LoggerService.csproj",
"chars": 407,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 5/AccountOwnerServer/Repository/AccountRepository.cs",
"chars": 310,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\n\nnamespace Repository\n{\n public class AccountRepository : Re"
},
{
"path": "Part 5/AccountOwnerServer/Repository/OwnerRepository.cs",
"chars": 903,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Repository\n{\n "
},
{
"path": "Part 5/AccountOwnerServer/Repository/Repository.csproj",
"chars": 364,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 5/AccountOwnerServer/Repository/RepositoryBase.cs",
"chars": 926,
"preview": "using Contracts;\nusing Entities;\nusing Microsoft.EntityFrameworkCore;\nusing System.Linq.Expressions;\n\nnamespace Reposit"
},
{
"path": "Part 5/AccountOwnerServer/Repository/RepositoryWrapper.cs",
"chars": 1095,
"preview": "using Contracts;\nusing Entities;\n\nnamespace Repository\n{\n public class RepositoryWrapper : IRepositoryWrapper \n {"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/AccountOwnerServer.csproj",
"chars": 580,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <Nullable>ena"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/Controllers/OwnerController.cs",
"chars": 6630,
"preview": "using AutoMapper;\nusing Contracts;\nusing Entities.DataTransferObjects;\nusing Entities.Models;\nusing Microsoft.AspNetCor"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/Extensions/ServiceExtensions.cs",
"chars": 1469,
"preview": "using Contracts;\nusing LoggerService;\nusing Microsoft.EntityFrameworkCore;\nusing Entities;\nusing Repository;\n\nnamespace"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/MappingProfile.cs",
"chars": 432,
"preview": "using AutoMapper;\nusing Entities.DataTransferObjects;\nusing Entities.Models;\nusing System.Linq;\n\nnamespace AccountOwner"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/Program.cs",
"chars": 987,
"preview": "using AccountOwnerServer.Extensions;\nusing Microsoft.AspNetCore.HttpOverrides;\nusing NLog;\n\nvar builder = WebApplication"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/Properties/launchSettings.json",
"chars": 809,
"preview": "{\n \"$schema\": \"https://json.schemastore.org/launchsettings.json\",\n \"iisSettings\": {\n \"windowsAuthentication\": fals"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/appsettings.Development.json",
"chars": 119,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n }\n}\n"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/appsettings.json",
"chars": 270,
"preview": "{\n \"Logging\": {\n \"LogLevel\": {\n \"Default\": \"Information\",\n \"Microsoft.AspNetCore\": \"Warning\"\n }\n },\n "
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer/nlog.config",
"chars": 625,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\n xmlns:xsi=\"htt"
},
{
"path": "Part 6/AccountOwnerServer/AccountOwnerServer.sln",
"chars": 3045,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.1.3221"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/Contracts.csproj",
"chars": 299,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/IAccountRepository.cs",
"chars": 161,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IAccountRepository\n {\n IEnumerable<Account"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/ILoggerManager.cs",
"chars": 227,
"preview": "namespace Contracts\n{\n public interface ILoggerManager\n {\n void LogInfo(string message);\n void LogW"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/IOwnerRepository.cs",
"chars": 350,
"preview": "using Entities.Models;\n\nnamespace Contracts\n{\n public interface IOwnerRepository\n {\n IEnumerable<Owner> Ge"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/IRepositoryBase.cs",
"chars": 402,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Text;\n\nn"
},
{
"path": "Part 6/AccountOwnerServer/Contracts/IRepositoryWrapper.cs",
"chars": 255,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Contracts\n{\n public interface IReposit"
},
{
"path": "Part 6/AccountOwnerServer/Entities/DataTransferObjects/AccountDto.cs",
"chars": 235,
"preview": "using System;\n\nnamespace Entities.DataTransferObjects\n{\n public class AccountDto\n {\n public Guid Id { get;"
},
{
"path": "Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerDto.cs",
"chars": 320,
"preview": "namespace Entities.DataTransferObjects\n{\n public class OwnerDto\n {\n public Guid Id { get; set; }\n p"
},
{
"path": "Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForCreationDto.cs",
"chars": 641,
"preview": "using System;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Entities.DataTransferObjects\n{\n public class O"
},
{
"path": "Part 6/AccountOwnerServer/Entities/DataTransferObjects/OwnerForUpdateDto.cs",
"chars": 637,
"preview": "using System;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Entities.DataTransferObjects\n{\n public class O"
},
{
"path": "Part 6/AccountOwnerServer/Entities/Entities.csproj",
"chars": 317,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 6/AccountOwnerServer/Entities/Models/Account.cs",
"chars": 606,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 6/AccountOwnerServer/Entities/Models/Owner.cs",
"chars": 807,
"preview": "using System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Entities.Mo"
},
{
"path": "Part 6/AccountOwnerServer/Entities/RepositoryContext.cs",
"chars": 359,
"preview": "using Entities.Models;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Entities\n{\n public class RepositoryContext : "
},
{
"path": "Part 6/AccountOwnerServer/LoggerService/LoggerManager.cs",
"chars": 478,
"preview": "using Contracts;\nusing NLog;\n\nnamespace LoggerService\n{\n public class LoggerManager : ILoggerManager\n {\n p"
},
{
"path": "Part 6/AccountOwnerServer/LoggerService/LoggerService.csproj",
"chars": 407,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 6/AccountOwnerServer/Repository/AccountRepository.cs",
"chars": 449,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\n\nnamespace Repository\n{\n public class AccountRepository : Re"
},
{
"path": "Part 6/AccountOwnerServer/Repository/OwnerRepository.cs",
"chars": 1095,
"preview": "using Contracts;\nusing Entities;\nusing Entities.Models;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Repository\n{\n "
},
{
"path": "Part 6/AccountOwnerServer/Repository/Repository.csproj",
"chars": 364,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>net9.0</TargetFramework>\n <ImplicitUsings>e"
},
{
"path": "Part 6/AccountOwnerServer/Repository/RepositoryBase.cs",
"chars": 926,
"preview": "using Contracts;\nusing Entities;\nusing Microsoft.EntityFrameworkCore;\nusing System.Linq.Expressions;\n\nnamespace Reposit"
},
{
"path": "Part 6/AccountOwnerServer/Repository/RepositoryWrapper.cs",
"chars": 1095,
"preview": "using Contracts;\nusing Entities;\n\nnamespace Repository\n{\n public class RepositoryWrapper : IRepositoryWrapper \n {"
},
{
"path": "README.md",
"chars": 85,
"preview": "# .NET-Core-Series\nCode Maze .NET Core Series\nhttps://code-maze.com/net-core-series/\n"
}
]
// ... and 2 more files (download for full content)
About this extraction
This page contains the full source code of the CodeMazeBlog/.NET-Core-Series GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 115 files (75.7 KB), approximately 23.4k tokens, and a symbol index with 206 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.