Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure Solution and Implemented Clean Architecture #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .github/delete.jpg
Binary file not shown.
Binary file removed .github/get.jpg
Binary file not shown.
Binary file removed .github/getSingle.jpg
Binary file not shown.
Binary file removed .github/patch.jpg
Binary file not shown.
Binary file removed .github/post.jpg
Binary file not shown.
Binary file removed .github/put.jpg
Binary file not shown.
Binary file removed .github/versions.jpg
Binary file not shown.
17 changes: 0 additions & 17 deletions .github/workflows/dotnetcore.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Dtos
namespace SampleWebApiAspNetCore.Domain.DataTransferObjects.Dtos
{
public class FoodCreateDto
{
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
namespace SampleWebApiAspNetCore.Dtos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Domain.DataTransferObjects.Dtos
{
public class FoodDto
{
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

namespace SampleWebApiAspNetCore.Dtos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Domain.DataTransferObjects.Dtos
{
public class FoodUpdateDto
{
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
namespace SampleWebApiAspNetCore.Entities
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Domain.Entities
{
public class FoodEntity
{
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
namespace SampleWebApiAspNetCore.Models
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Domain.Models
{
public class LinkDto
{
@@ -13,4 +19,4 @@ public LinkDto(string href, string rel, string method)
Method = method;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

namespace SampleWebApiAspNetCore.Models
namespace SampleWebApiAspNetCore.Domain.Models
{
public class QueryParameters
{
@@ -16,5 +15,10 @@ public int PageCount
public string? Query { get; set; } = "";

public string OrderBy { get; set; } = "Name";
public bool IsDescending { get; set; } = false;
public bool HasQuery
{
get { return !string.IsNullOrEmpty(Query);}
}
}
}
}
13 changes: 13 additions & 0 deletions SampleWebApiAspNetCore.Domain/SampleWebApiAspNetCore.Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Folder Include="DataTransferObjects\DtoValidators\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Helpers
namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class CorsExtension
{
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Models
namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class DynamicExtensions
{
@@ -18,4 +22,4 @@ public static dynamic ToDynamic(this object value)
return expando as ExpandoObject;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;

namespace SampleWebApiAspNetCore.Helpers
namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class ExceptionExtension
{
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using SampleWebApiAspNetCore.Models;


namespace SampleWebApiAspNetCore.Helpers
using SampleWebApiAspNetCore.Domain.Models;

namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class QueryParametersExtensions
{
@@ -33,4 +35,4 @@ public static bool IsDescending(this QueryParameters queryParameters)
return false;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
using SampleWebApiAspNetCore.Repositories;
using SampleWebApiAspNetCore.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SampleWebApiAspNetCore.Data;
using SampleWebApiAspNetCore.Service.Services.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Helpers
namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class SeedDataExtension
{
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Helpers
namespace SampleWebApiAspNetCore.Service.Helpers
{
public static class VersioningExtension
{
@@ -18,15 +23,13 @@ public static void AddVersioning(this IServiceCollection services)
new HeaderApiVersionReader("x-api-version"),
new MediaTypeApiVersionReader("x-api-version"));
});
services.AddVersionedApiExplorer(
options =>
{
options.GroupNameFormat = "'v'VVV";

// note: this option is only necessary when versioning by url segment. the SubstitutionFormat
// can also be used to control the format of the API version in route templates
options.SubstituteApiVersionInUrl = true;
});
services.AddApiVersioning(x =>
{
x.DefaultApiVersion = new ApiVersion(1, 0);
x.AssumeDefaultVersionWhenUnspecified = true;
x.ReportApiVersions = true;
//x.ApiVersionReader = new HeaderApiVersionReader("x-api-version");
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using AutoMapper;
using SampleWebApiAspNetCore.Dtos;
using SampleWebApiAspNetCore.Entities;
using SampleWebApiAspNetCore.Domain.DataTransferObjects.Dtos;
using SampleWebApiAspNetCore.Domain.Entities;

namespace SampleWebApiAspNetCore.MappingProfiles
namespace SampleWebApiAspNetCore.Service.Mapper
{
public class FoodMappings : Profile
{
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SampleWebApiAspNetCore.Domain\SampleWebApiAspNetCore.Domain.csproj" />
<ProjectReference Include="..\SamplwWebApiAspNetCore.Data\SampleWebApiAspNetCore.Data.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using SampleWebApiAspNetCore.Models;
using SampleWebApiAspNetCore.Helpers;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using SampleWebApiAspNetCore.Domain.Models;
using SampleWebApiAspNetCore.Service.Helpers;
using SampleWebApiAspNetCore.Service.Services.Interfaces;
using System.Reflection;

namespace SampleWebApiAspNetCore.Services
namespace SampleWebApiAspNetCore.Service.Services.Implementations
{
public class LinkService<T> : ILinkService<T>
{
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using SampleWebApiAspNetCore.Entities;
using SampleWebApiAspNetCore.Repositories;
using SampleWebApiAspNetCore.Data;
using SampleWebApiAspNetCore.Domain.Entities;
using SampleWebApiAspNetCore.Service.Services.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWebApiAspNetCore.Services
namespace SampleWebApiAspNetCore.Service.Services.Implementations
{
public class SeedDataService : ISeedDataService
{
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using SampleWebApiAspNetCore.Models;
using SampleWebApiAspNetCore.Domain.Models;

namespace SampleWebApiAspNetCore.Services
namespace SampleWebApiAspNetCore.Service.Services.Interfaces
{
public interface ILinkService<T>
{
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SampleWebApiAspNetCore.Repositories;
using SampleWebApiAspNetCore.Data;

namespace SampleWebApiAspNetCore.Services
namespace SampleWebApiAspNetCore.Service.Services.Interfaces
{
public interface ISeedDataService
{
20 changes: 19 additions & 1 deletion SampleWebApiAspNetCore.sln
Original file line number Diff line number Diff line change
@@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApiAspNetCore", "SampleWebApiAspNetCore\SampleWebApiAspNetCore.csproj", "{36DF3175-0775-44CC-8708-5B67F2ED70FE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApiAspNetCore", "SampleWebApiAspNetCore\SampleWebApiAspNetCore.csproj", "{36DF3175-0775-44CC-8708-5B67F2ED70FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApiAspNetCore.Data", "SamplwWebApiAspNetCore.Data\SampleWebApiAspNetCore.Data.csproj", "{F8A0B9B1-740C-4512-B416-14908B05BB04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApiAspNetCore.Domain", "SampleWebApiAspNetCore.Domain\SampleWebApiAspNetCore.Domain.csproj", "{97C27773-DBE8-40DD-9B74-ACE0337DBD2C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApiAspNetCore.Service", "SampleWebApiAspNetCore.Service\SampleWebApiAspNetCore.Service.csproj", "{3F208067-DCD5-4F2E-B1E5-A2502B0B5495}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +21,18 @@ Global
{36DF3175-0775-44CC-8708-5B67F2ED70FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36DF3175-0775-44CC-8708-5B67F2ED70FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36DF3175-0775-44CC-8708-5B67F2ED70FE}.Release|Any CPU.Build.0 = Release|Any CPU
{F8A0B9B1-740C-4512-B416-14908B05BB04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8A0B9B1-740C-4512-B416-14908B05BB04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8A0B9B1-740C-4512-B416-14908B05BB04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8A0B9B1-740C-4512-B416-14908B05BB04}.Release|Any CPU.Build.0 = Release|Any CPU
{97C27773-DBE8-40DD-9B74-ACE0337DBD2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97C27773-DBE8-40DD-9B74-ACE0337DBD2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97C27773-DBE8-40DD-9B74-ACE0337DBD2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97C27773-DBE8-40DD-9B74-ACE0337DBD2C}.Release|Any CPU.Build.0 = Release|Any CPU
{3F208067-DCD5-4F2E-B1E5-A2502B0B5495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F208067-DCD5-4F2E-B1E5-A2502B0B5495}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F208067-DCD5-4F2E-B1E5-A2502B0B5495}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F208067-DCD5-4F2E-B1E5-A2502B0B5495}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
12 changes: 6 additions & 6 deletions SampleWebApiAspNetCore/Controllers/v1/FoodsController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using AutoMapper;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using SampleWebApiAspNetCore.Dtos;
using SampleWebApiAspNetCore.Entities;
using SampleWebApiAspNetCore.Helpers;
using SampleWebApiAspNetCore.Services;
using SampleWebApiAspNetCore.Models;
using SampleWebApiAspNetCore.Repositories;
using SampleWebApiAspNetCore.Data.Repositories.Interfaces;
using SampleWebApiAspNetCore.Domain.DataTransferObjects.Dtos;
using SampleWebApiAspNetCore.Domain.Entities;
using SampleWebApiAspNetCore.Domain.Models;
using SampleWebApiAspNetCore.Service.Helpers;
using SampleWebApiAspNetCore.Service.Services.Interfaces;
using System.Text.Json;

namespace SampleWebApiAspNetCore.Controllers.v1
Loading
Oops, something went wrong.