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

Sprint 2 #85

Merged
merged 91 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
7ff8016
add coding conventions section in contributing doc
MostafaTech Oct 24, 2023
9da3f38
add some other code conventions resources
MostafaTech Oct 26, 2023
8022bd0
Initial Content Type Implementation
ParsaGachkar Oct 26, 2023
cbffe92
Improve implmentation
ParsaGachkar Oct 26, 2023
288d3bf
fix warnings
ParsaGachkar Oct 26, 2023
e5113b2
Add Field Settings
ParsaGachkar Oct 26, 2023
4dac664
#51 add simple UI and API with initial projects layered and structure
pournasserian Oct 27, 2023
9787305
Refactor Content Type
ParsaGachkar Oct 29, 2023
392b6da
Implement repository
ParsaGachkar Oct 29, 2023
ca473ba
Implement Service
ParsaGachkar Oct 29, 2023
015f9ac
ContentType Crud Test success
ParsaGachkar Oct 29, 2023
8cb356c
Merge pull request #46 from fluentcms/45-add-coding-conventions-to-co…
MostafaTech Oct 29, 2023
656eb22
Add missing Methods and Test cases
ParsaGachkar Oct 29, 2023
86a590c
Implement #18
ParsaGachkar Oct 29, 2023
230a0b8
remove compiled app.css files from scss and igonre them in gitignore
MostafaTech Oct 29, 2023
9be7679
move projects to .net v8.0-rc
MostafaTech Oct 29, 2023
2347636
add core and repository to ui project
MostafaTech Oct 29, 2023
03eb135
Merge pull request #72 from fluentcms/51-create-a-project-for-razor-c…
MostafaTech Oct 29, 2023
4e3020e
Test Defualt Value
ParsaGachkar Oct 30, 2023
60ca5dd
Merge pull request #58 from fluentcms/57-initial-implementation-of-co…
MostafaTech Oct 30, 2023
aca16eb
some refactors and nuget package updates
MostafaTech Oct 30, 2023
6d0587e
add application layer and add user basic actions
MostafaTech Oct 30, 2023
a1a5f46
Merge pull request #87 from fluentcms/86-implementing-basic-applicati…
ParsaGachkar Oct 30, 2023
756f250
implement Site Entity
ParsaGachkar Oct 30, 2023
e96d04b
Implement Site Repository
ParsaGachkar Oct 30, 2023
e293553
Implement Site Service
ParsaGachkar Oct 30, 2023
759e9f3
Implement Tests for SiteService
ParsaGachkar Oct 30, 2023
b1aac00
refactor site tests
ParsaGachkar Oct 30, 2023
6b1c6e0
implement Commands and Queries
ParsaGachkar Oct 30, 2023
24603dc
Implement WebApi's
ParsaGachkar Oct 30, 2023
cedc1b9
add users list to blazor ui app
MostafaTech Oct 31, 2023
41dce24
fix some formattings in site related classes
MostafaTech Oct 31, 2023
7a55056
enhance command namings
ParsaGachkar Oct 31, 2023
c8faea0
remove unnecessary field
ParsaGachkar Oct 31, 2023
94006ae
fix confilict
ParsaGachkar Oct 31, 2023
100d81c
Merge remote-tracking branch 'origin/76-add-simple-crud-for-user' int…
ParsaGachkar Oct 31, 2023
d01e5c4
fix merge formatting issues in code
MostafaTech Oct 31, 2023
be1acef
Merge branch '73-add-simple-crud-for-site-from-sprint-2' of https://g…
ParsaGachkar Oct 31, 2023
3a2d04e
Update Commands and Queries Id Field
ParsaGachkar Oct 31, 2023
c98b0ed
Merge pull request #90 from fluentcms/73-add-simple-crud-for-site-fro…
ParsaGachkar Oct 31, 2023
cce6f19
implement Site List
ParsaGachkar Oct 31, 2023
0a1ea16
Implement Site List UI
ParsaGachkar Oct 31, 2023
21a16ed
Merge pull request #93 from fluentcms/73-add-simple-crud-for-site-fro…
MostafaTech Oct 31, 2023
6d93866
add create and edit user pages and delete
MostafaTech Oct 31, 2023
88fad5d
Merge pull request #95 from fluentcms/76-add-simple-crud-for-user
MostafaTech Oct 31, 2023
ec87c16
fix SucessResult method name
MostafaTech Oct 31, 2023
6c0a122
set Repository GetById as nullable
MostafaTech Oct 31, 2023
84037ed
Merge pull request #97 from fluentcms/38-nullable-return-types-should…
MostafaTech Oct 31, 2023
2c154f8
move User entity to Users folder
MostafaTech Oct 31, 2023
260c299
Implement Entity
ParsaGachkar Nov 1, 2023
f76bc8f
Implement Repository
ParsaGachkar Nov 1, 2023
4a99de6
Implement PageService
ParsaGachkar Nov 1, 2023
0fb01f1
Update PageRepository
ParsaGachkar Nov 1, 2023
87c5d31
Update Page Constructor
ParsaGachkar Nov 1, 2023
d0102f8
Test Page Service
ParsaGachkar Nov 1, 2023
c00c73f
add roles and userRoles with ui crud
MostafaTech Nov 1, 2023
0a53689
Merge pull request #105 from fluentcms/75-add-simple-crud-for-role
MostafaTech Nov 1, 2023
9349da4
refactor user entity to store userRoles inside its document in litedb
MostafaTech Nov 2, 2023
cf64731
Merge pull request #108 from fluentcms/107-refactor-user-entity-to-st…
MostafaTech Nov 2, 2023
3f428b1
delete weatherforecast from project
MostafaTech Nov 2, 2023
6f0ce9c
add roles list, edit and delete ui forms
MostafaTech Nov 2, 2023
c99f3c7
Merge pull request #109 from fluentcms/100-delete-weatherforcast-cont…
MostafaTech Nov 2, 2023
86ef36c
put all admin pages insode /admin route
MostafaTech Nov 2, 2023
cab3d12
Merge pull request #111 from fluentcms/110-put-all-ui-pages-inside-ad…
pournasserian Nov 2, 2023
873a161
remove mediatR and add application services
MostafaTech Nov 2, 2023
f60e626
replace PagingResponse with SearchXResponse in api results
MostafaTech Nov 2, 2023
65abcf8
add fluent validation
MostafaTech Nov 3, 2023
a0f17e1
#112 major refactor in repositories
pournasserian Nov 3, 2023
387267d
#112 add MongoDb and basic controller, service structure
pournasserian Nov 3, 2023
d9fe01d
#112 add Sample WebApi (ONLY) project
pournasserian Nov 4, 2023
0952b1a
#112 change Result to ApiResult
pournasserian Nov 4, 2023
e5c053d
#112 add Automapper & MongoDB bug fixing
pournasserian Nov 4, 2023
32eae04
#112 resolving Guid issue on MongoDb
pournasserian Nov 4, 2023
2099d90
#112 ensure site deletion
pournasserian Nov 4, 2023
3fa4bcb
#112 add SeedData feature to Api
pournasserian Nov 4, 2023
6745d18
#112 removing unused appsettings.json in Api root
pournasserian Nov 4, 2023
3d3850d
Merge pull request #113 from fluentcms/112-refactor-project-architect…
MostafaTech Nov 5, 2023
2254e7d
mergeback 74-add-simple-crud-for-page to sprint-2
MostafaTech Nov 5, 2023
b70d330
fix tests and formattings
MostafaTech Nov 5, 2023
9dd9f18
refactor new structure based on tech meeting
MostafaTech Nov 5, 2023
1fc0bcf
Merge pull request #116 from fluentcms/112-refactor-based-on-sunday-m…
pournasserian Nov 5, 2023
2377e95
fix errors and dbfile location of latest refactor
MostafaTech Nov 6, 2023
ddabb05
Accept changes from Sprint-2
ParsaGachkar Nov 6, 2023
a0bf231
Fix Base Repository Tests
ParsaGachkar Nov 6, 2023
565cee2
fix site tests
ParsaGachkar Nov 6, 2023
86912d5
update page tests
ParsaGachkar Nov 6, 2023
92aea78
clean up unused files
ParsaGachkar Nov 6, 2023
4e199f4
Implement Edit and Delete for Page
ParsaGachkar Nov 6, 2023
8adf4ec
update page CRUD
ParsaGachkar Nov 6, 2023
f72880d
fix some formatting for pages feature
MostafaTech Nov 6, 2023
f385d6f
Merge pull request #104 from fluentcms/74-add-simple-crud-for-page
MostafaTech Nov 6, 2023
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
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ All contributors are expected to adhere to our [Code of Conduct](./CODE_OF_CONDU
```bash
git checkout -b feature/your-feature-name

## Coding Conventions

Before you want to start making your changes, consider these conventions in your codes:
- [Naming Conventions by Microsoft](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-guidelines)
- [C# identifier naming rules and conventions by Microsoft](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names)
- [Common C# code conventions by Microsoft](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)

## Submitting Changes

Once you've made your changes, push the branch to your fork on GitHub. Navigate to the main FluentCMS repository and create a new Pull Request. Ensure your PR title is descriptive, and include "Fixes #IssueNumber" if your PR closes a specific issue. In the PR description, provide a detailed overview of the changes.
Expand Down
6 changes: 6 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# Client packages (bootstrap, etc.)
lib/

# Compiled css
/FluentCMS.Web.UI/wwwroot/css/*.css

# User-specific files
*.rsuser
*.suo
Expand Down
36 changes: 36 additions & 0 deletions src/FluentCMS.Api/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Hosting;

namespace Microsoft.Extensions.Configuration;

public static class ConfigurationExtensions
{
public static IConfigurationBuilder AddConfig(this IConfigurationBuilder configBuilder, IHostEnvironment env, string configFolder = "\\Config\\")
{
var folderName = env.ContentRootPath + configFolder;

// setting base path for config folder
configBuilder.SetBasePath(folderName);

foreach (var filename in Directory.GetFiles(folderName))
{
// read only json files
if (Path.GetExtension(filename) != ".json")
continue;

// accept only root config files
if (Path.GetFileName(filename).Split(".").Length != 2)
continue;

// adding config file
configBuilder.AddJsonFile(filename, optional: true, reloadOnChange: true)
.AddJsonFile($"{Path.GetFileNameWithoutExtension(filename)}.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
}

return configBuilder;
}

public static T? GetInstance<T>(this IConfiguration configuration, string sectionName)
{
return configuration.GetSection(sectionName).Get<T>();
}
}
10 changes: 10 additions & 0 deletions src/FluentCMS.Api/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Mvc;

namespace FluentCMS.Api.Controllers;

[ApiController]
[Route("api/[controller]/[action]")]
[Produces("application/json")]
public abstract class BaseController
{
}
70 changes: 70 additions & 0 deletions src/FluentCMS.Api/Controllers/PagesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using AutoMapper;
using FluentCMS.Api.Models;
using FluentCMS.Api.Models.Pages;
using FluentCMS.Entities.Pages;
using FluentCMS.Services;
using Microsoft.AspNetCore.Mvc;

namespace FluentCMS.Api.Controllers;

public class PagesController : BaseController
{
private readonly IPageService _pageService;
private readonly IMapper _mapper;

public PagesController(IPageService pageService, IMapper mapper)
{
_pageService = pageService;
_mapper = mapper;
}

// GetBy Site and ParentId
[HttpPost]
public async Task<IApiPagingResult<PageResponse>> GetAll([FromBody] PageSearchRequest request)
{
var pages = await _pageService.GetBySiteIdAndParentId(request.SiteId, request.ParentId);
return new ApiPagingResult<PageResponse>(_mapper.Map<List<PageResponse>>(pages));
}

[HttpGet("{id}")]
public async Task<IApiResult<PageResponse>> GetById([FromRoute] Guid id)
{
var page = await _pageService.GetById(id);
var pageResponse = _mapper.Map<PageResponse>(page);
// map recursive?
await MapChildren(id, pageResponse);
return new ApiResult<PageResponse>(pageResponse);
}

private async Task MapChildren(Guid id, PageResponse pageResponse)
{
var childrenPage = await _pageService.GetByParentId(id);
pageResponse.Children = childrenPage.Select(x => _mapper.Map<PageResponse>(x));
}

[HttpPost]
public async Task<IApiResult<PageResponse>> Create(CreatePageRequest request)
{
var page = _mapper.Map<Page>(request);
var newPage = await _pageService.Create(page);
var pageResponse = _mapper.Map<PageResponse>(newPage);
return new ApiResult<PageResponse>(pageResponse);
}

[HttpPut]
public async Task<IApiResult<PageResponse>> Edit(EditPageRequest request)
{
var page = _mapper.Map<Page>(request);
var updatedPage = await _pageService.Edit(page);
var pageResponse = _mapper.Map<PageResponse>(updatedPage);
return new ApiResult<PageResponse>(pageResponse);
}

[HttpDelete("{id}")]
public async Task<IApiResult<bool>> Delete([FromRoute] Guid id)
{
var page = await _pageService.GetById(id);
await _pageService.Delete(page);
return new ApiResult<bool>(true);
}
}
52 changes: 52 additions & 0 deletions src/FluentCMS.Api/Controllers/RolesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using AutoMapper;
using FluentCMS.Api.Models;
using FluentCMS.Api.Models.Users;
using FluentCMS.Entities.Users;
using FluentCMS.Services;
using Microsoft.AspNetCore.Mvc;

namespace FluentCMS.Api.Controllers;
public class RolesController(IMapper mapper, IRoleService roleService) : BaseController
{
[HttpGet]
public async Task<IApiPagingResult<RoleResponse>> GetAll([FromQuery] SearchRoleRequest request)
{
var roles = await roleService.GetAll();
var result = mapper.Map<IEnumerable<RoleResponse>>(roles);
return new ApiPagingResult<RoleResponse>(result);
}

[HttpGet("{id}")]
public async Task<IApiResult<RoleResponse>> GetById([FromRoute] Guid id)
{
var role = await roleService.GetById(id);
var result = mapper.Map<RoleResponse>(role);
return new ApiResult<RoleResponse>(result);
}

[HttpPost]
public async Task<IApiResult<RoleResponse>> Create(CreateRoleRequest request)
{
var role = mapper.Map<Role>(request);
var newRole = await roleService.Create(role);
var result = mapper.Map<RoleResponse>(newRole);
return new ApiResult<RoleResponse>(result);
}

[HttpPut]
public async Task<IApiResult<RoleResponse>> Edit(EditRoleRequest request)
{
var role = mapper.Map<Role>(request);
var editedRole = await roleService.Edit(role);
var result = mapper.Map<RoleResponse>(editedRole);
return new ApiResult<RoleResponse>(result);
}

[HttpDelete("{id}")]
public async Task<IApiResult<bool>> Delete([FromRoute] Guid id)
{
var role = await roleService.GetById(id);
await roleService.Delete(role);
return new ApiResult<bool>(true);
}
}
82 changes: 82 additions & 0 deletions src/FluentCMS.Api/Controllers/SiteController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using AutoMapper;
using FluentCMS.Api.Models;
using FluentCMS.Api.Models.Sites;
using FluentCMS.Api.Models.Pages;
using FluentCMS.Entities.Sites;
using FluentCMS.Services;
using Microsoft.AspNetCore.Mvc;

namespace FluentCMS.Api.Controllers;

public class SiteController : BaseController
{
private readonly ISiteService _siteService;
private readonly IPageService _pageService;
private readonly IMapper _mapper;

public SiteController(ISiteService siteService, IPageService pageService, IMapper mapper)
{
_siteService = siteService;
_pageService = pageService;
_mapper = mapper;
}

[HttpGet]
public async Task<IApiPagingResult<SiteResponse>> GetAll([FromQuery] SearchSiteRequest request, CancellationToken cancellationToken = default)
{
var sites = await _siteService.GetAll(cancellationToken);
var siteResponses = _mapper.Map<List<SiteResponse>>(sites);
return new ApiPagingResult<SiteResponse>(siteResponses);
}

[HttpGet("{id}")]
public async Task<IApiResult<SiteResponse>> GetById(Guid id, CancellationToken cancellationToken = default)
{
var site = await _siteService.GetById(id, cancellationToken);
var pages = await _pageService.GetBySiteId(site.Id, cancellationToken);

var siteResponse = _mapper.Map<SiteResponse>(site);
siteResponse.Pages = _mapper.Map<List<PageResponse>>(pages);

return new ApiResult<SiteResponse>(siteResponse);
}

[HttpGet]
public async Task<IApiResult<SiteResponse>> GetByUrl([FromQuery] string url, CancellationToken cancellationToken = default)
{
// TODO: should we change Url to domain?
var site = await _siteService.GetByUrl(url, cancellationToken);
var pages = await _pageService.GetBySiteId(site.Id, cancellationToken);

var siteResponse = _mapper.Map<SiteResponse>(site);
siteResponse.Pages = _mapper.Map<List<PageResponse>>(pages);

return new ApiResult<SiteResponse>(siteResponse);
}

[HttpPost]
public async Task<IApiResult<SiteResponse>> Create(CreateSiteRequest request, CancellationToken cancellationToken = default)
{
var site = _mapper.Map<Site>(request);
var newSite = await _siteService.Create(site, cancellationToken);
var siteResponse = _mapper.Map<SiteResponse>(newSite);
return new ApiResult<SiteResponse>(siteResponse);
}

[HttpPatch]
public async Task<IApiResult<SiteResponse>> Edit(EditSiteRequest request, CancellationToken cancellationToken = default)
{
var site = _mapper.Map<Site>(request);
var updateSite = await _siteService.Edit(site, cancellationToken);
var siteResponse = _mapper.Map<SiteResponse>(updateSite);
return new ApiResult<SiteResponse>(siteResponse);
}

[HttpDelete("{id}")]
public async Task<IApiResult> Delete([FromRoute] Guid id, CancellationToken cancellationToken = default)
{
var site = await _siteService.GetById(id);
await _siteService.Delete(site, cancellationToken);
return new ApiResult();
}
}
65 changes: 65 additions & 0 deletions src/FluentCMS.Api/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using AutoMapper;
using FluentCMS.Api.Models;
using FluentCMS.Api.Models.Users;
using FluentCMS.Entities.Users;
using FluentCMS.Services;
using Microsoft.AspNetCore.Mvc;

namespace FluentCMS.Api.Controllers;
public class UsersController(IMapper mapper, IUserService userService) : BaseController
{
[HttpGet]
public async Task<IApiPagingResult<UserResponse>> GetAll([FromQuery] SearchUserRequest request)
{
var users = await userService.GetAll();
var result = mapper.Map<IEnumerable<UserResponse>>(users);
return new ApiPagingResult<UserResponse>(result);
}

[HttpGet("{id}")]
public async Task<IApiResult<UserResponse>> GetById([FromRoute] Guid id)
{
var user = await userService.GetById(id);
var result = mapper.Map<UserResponse>(user);
return new ApiResult<UserResponse>(result);
}

[HttpPost]
public async Task<IApiResult<UserResponse>> Create(CreateUserRequest request)
{
var user = mapper.Map<User>(request);
user.Id = Guid.NewGuid();
user.UserRoles = request.Roles?.Select(x => new UserRole
{
Id = Guid.NewGuid(),
UserId = user.Id,
RoleId = x
}).ToList() ?? [];
var newUser = await userService.Create(user);
var result = mapper.Map<UserResponse>(newUser);
return new ApiResult<UserResponse>(result);
}

[HttpPut]
public async Task<IApiResult<UserResponse>> Edit(EditUserRequest request)
{
var user = mapper.Map<User>(request);
user.UserRoles = request.Roles?.Select(x => new UserRole
{
Id = Guid.NewGuid(),
UserId = user.Id,
RoleId = x
}).ToList() ?? [];
var editedUser = await userService.Edit(user);
var result = mapper.Map<UserResponse>(editedUser);
return new ApiResult<UserResponse>(result);
}

[HttpDelete("{id}")]
public async Task<IApiResult<bool>> Delete([FromRoute] Guid id)
{
var user = await userService.GetById(id);
await userService.Delete(user);
return new ApiResult<bool>(true);
}
}
42 changes: 42 additions & 0 deletions src/FluentCMS.Api/FluentCMS.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<None Remove="SeedData\pages.json" />
<None Remove="SeedData\site.json" />
</ItemGroup>

<ItemGroup>
<Content Include="SeedData\pages.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="SeedData\site.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation" Version="11.8.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="SharpGrip.FluentValidation.AutoValidation.Mvc" Version="1.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FluentCMS.Services\FluentCMS.Services.csproj" />
</ItemGroup>

</Project>
Loading