Skip to content

Commit 1db96de

Browse files
author
Okeanij
committed
Components => Sections
1 parent bfeef87 commit 1db96de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+388
-396
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ orleans.codegen.cs
243243
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
244244
#*.snk
245245

246-
# Since there are multiple workflows, uncomment next line to ignore bower_components
246+
# Since there are multiple workflows, uncomment next line to ignore bower_Sections
247247
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
248-
#bower_components/
248+
#bower_Sections/
249249
# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
250250
**/wwwroot/lib/
251251

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ Build on: AspNet Core, VueJS, Quasar.</h3>
5151
- Interactive editing of site menu, as well as additional menus
5252
- Switch basic and additional skins
5353
- User groups and changing their permissions
54-
- Creating site activities components
54+
- Creating site activities Sections
5555
- And other features...
5656

5757
## Technical features
5858
### Technologies used
5959
The project based on modern front edge technologies:
6060
- Asp.Net Core 3.1
6161
- VueJs - SPA client part
62-
- Quasar Framework - Material Design VueJs components
62+
- Quasar Framework - Material Design VueJs Sections
6363
- PostgreSQL - database (in the future, other SQL db engines)
6464
- Linq2db ORM - database access
6565

Server/SunEngine.Admin/AddAdminExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public static void AddAdmin(this IServiceCollection services)
1212
services.AddScoped<CategoriesAdminManager>();
1313
services.AddScoped<IConfigurationManager, ConfigurationManager>();
1414
services.AddScoped<IMenuAdminManager, MenuAdminManager>();
15-
services.AddScoped<IComponentsAdminManager, ComponentsAdminManager>();
15+
services.AddScoped<ISectionsAdminManager, SectionsAdminManager>();
1616

1717
services.AddScoped<IUserRolesAdminPresenter, UserRolesAdminPresenter>();
1818
services.AddScoped<ICategoriesAdminPresenter, CategoriesAdminPresenter>();
1919
services.AddScoped<IUserRolesAdminPresenter, UserRolesAdminPresenter>();
2020
services.AddScoped<IMenuAdminPresenter, MenuAdminPresenter>();
21-
services.AddScoped<IComponentsAdminPresenter, ComponentsAdminPresenter>();
21+
services.AddScoped<ISectionsAdminPresenter, SectionsAdminPresenter>();
2222
services.AddScoped<IConfigurationPresenter, ConfigurationPresenter>();
2323

2424
services.AddScoped<RolesPermissionsAdminService>();

Server/SunEngine.Admin/Controllers/CacheAdminController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SunEngine.Admin.Controllers
88
{
99
public class CacheAdminController : BaseAdminController
1010
{
11-
protected readonly IComponentsCache componentsCache;
11+
protected readonly ISectionsCache SectionsCache;
1212
protected readonly ICategoriesCache categoriesCache;
1313
protected readonly IMenuCache menuCache;
1414
protected readonly SpamProtectionCache spamProtectionCache;
@@ -18,7 +18,7 @@ public class CacheAdminController : BaseAdminController
1818
protected readonly SanitizerService sanitizerService;
1919

2020
public CacheAdminController(
21-
IComponentsCache componentsCache,
21+
ISectionsCache sectionsCache,
2222
ICategoriesCache categoriesCache,
2323
IMenuCache menuCache,
2424
SpamProtectionCache spamProtectionCache,
@@ -28,7 +28,7 @@ public CacheAdminController(
2828
SanitizerService sanitizerService,
2929
IServiceProvider serviceProvider) : base(serviceProvider)
3030
{
31-
this.componentsCache = componentsCache;
31+
this.SectionsCache = sectionsCache;
3232
this.categoriesCache = categoriesCache;
3333
this.menuCache = menuCache;
3434
this.spamProtectionCache = spamProtectionCache;
@@ -40,7 +40,7 @@ public CacheAdminController(
4040

4141
public IActionResult ResetAllCache()
4242
{
43-
componentsCache.Initialize();
43+
SectionsCache.Initialize();
4444
categoriesCache.Initialize();
4545
menuCache.Initialize();
4646
rolesCache.Initialize();

Server/SunEngine.Admin/Controllers/ComponentsAdminController.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

Server/SunEngine.Admin/Controllers/DeletedElementsController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Threading.Tasks;
33
using Microsoft.AspNetCore.Mvc;
4+
using SunEngine.Admin.Managers;
45
using SunEngine.Admin.Services;
56

67
namespace SunEngine.Admin.Controllers
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Microsoft.AspNetCore.Mvc;
4+
using SunEngine.Admin.Managers;
5+
using SunEngine.Admin.Presenters;
6+
using SunEngine.Core.Cache.Services;
7+
using SunEngine.Core.Models;
8+
9+
namespace SunEngine.Admin.Controllers
10+
{
11+
public class SectionsAdminController : BaseAdminController
12+
{
13+
protected readonly ISectionsAdminPresenter SectionsAdminPresenter;
14+
protected readonly ISectionsAdminManager SectionsAdminManager;
15+
protected readonly ISectionsCache SectionsCache;
16+
17+
public SectionsAdminController(
18+
ISectionsAdminPresenter SectionsAdminPresenter,
19+
ISectionsAdminManager SectionsAdminManager,
20+
ISectionsCache SectionsCache,
21+
IServiceProvider serviceProvider) : base(serviceProvider: serviceProvider)
22+
{
23+
this.SectionsAdminPresenter = SectionsAdminPresenter;
24+
this.SectionsAdminManager = SectionsAdminManager;
25+
this.SectionsCache = SectionsCache;
26+
}
27+
28+
[HttpPost]
29+
public async Task<IActionResult> GetAllSections()
30+
{
31+
var rez = await SectionsAdminPresenter.GetSectionsAsync();
32+
return Ok(rez);
33+
}
34+
35+
[HttpPost]
36+
public async Task<IActionResult> GetComponent(string name)
37+
{
38+
var component = await SectionsAdminPresenter.GetComponentAsync(name);
39+
return Ok(component);
40+
}
41+
42+
[HttpPost]
43+
public async Task<IActionResult> AddComponent([FromBody] Section section)
44+
{
45+
await SectionsAdminManager.CreateComponentAsync(section);
46+
47+
SectionsCache.Initialize();
48+
49+
return Ok();
50+
}
51+
52+
[HttpPost]
53+
public async Task<IActionResult> UpdateComponent([FromBody] Section section)
54+
{
55+
await SectionsAdminManager.UpdateComponentAsync(section);
56+
57+
SectionsCache.Initialize();
58+
59+
return Ok();
60+
}
61+
62+
[HttpPost]
63+
public async Task<IActionResult> DeleteComponent(int componentId)
64+
{
65+
await SectionsAdminManager.DeleteComponentAsync(componentId);
66+
67+
SectionsCache.Initialize();
68+
69+
return Ok();
70+
}
71+
}
72+
}

Server/SunEngine.Admin/Managers/CleanerManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using SunEngine.Core.DataBase;
66
using SunEngine.Core.Models.Materials;
77

8-
namespace SunEngine.Admin.Services
8+
namespace SunEngine.Admin.Managers
99
{
1010
public interface ICleanerManager
1111
{

Server/SunEngine.Admin/Managers/ComponentsAdminManager.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

Server/SunEngine.Admin/Managers/ConfigurationManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using LinqToDB.Data;
55
using SunEngine.Core.Cache.Services;
66
using SunEngine.Core.Configuration;
7+
using SunEngine.Core.Configuration.ConfigItemType;
78
using SunEngine.Core.DataBase;
89
using SunEngine.Core.Models;
910
using SunEngine.Core.Services;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Linq;
2+
using System.Threading.Tasks;
3+
using LinqToDB;
4+
using SunEngine.Core.Cache.Services;
5+
using SunEngine.Core.DataBase;
6+
using SunEngine.Core.Models;
7+
using SunEngine.Core.Services;
8+
using SunEngine.Core.Utils;
9+
10+
namespace SunEngine.Admin.Managers
11+
{
12+
public interface ISectionsAdminManager
13+
{
14+
Task CreateComponentAsync(Section section);
15+
Task UpdateComponentAsync(Section section);
16+
Task DeleteComponentAsync(int componentId);
17+
}
18+
19+
public class SectionsAdminManager : DbService, ISectionsAdminManager
20+
{
21+
protected readonly IRolesCache rolesCache;
22+
23+
public SectionsAdminManager(
24+
IRolesCache rolesCache,
25+
DataBaseConnection db) : base(db)
26+
{
27+
this.rolesCache = rolesCache;
28+
}
29+
30+
public Task CreateComponentAsync(Section section)
31+
{
32+
section.Options = section.Options?.MakeJsonTextNotNull();
33+
section.Roles = rolesCache.CheckAndSetRoles(section.Roles);
34+
35+
return db.InsertWithIdentityAsync(section);
36+
}
37+
38+
public Task UpdateComponentAsync(Section section)
39+
{
40+
section.Options = section.Options?.MakeJsonTextNotNull();
41+
section.Roles = rolesCache.CheckAndSetRoles(section.Roles);
42+
43+
return db.UpdateAsync(section);
44+
}
45+
46+
public Task DeleteComponentAsync(int sectionId)
47+
{
48+
return db.Sections.Where(x => x.Id == sectionId).DeleteAsync();
49+
}
50+
}
51+
}

Server/SunEngine.Admin/Presenters/ComponentsAdminPresenter.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)