Compare commits
71 Commits
1b21ccecf3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3832351dd1 | ||
|
|
99237cbecc | ||
|
|
cb2edffe91 | ||
|
|
4d3768248e | ||
|
|
fb38bc1fd4 | ||
|
|
10b557374d | ||
|
|
f266e6728f | ||
|
|
3373fceef3 | ||
|
|
f7eaa0f7de | ||
|
|
d5b1ee41a0 | ||
|
|
c3f5d90b6a | ||
|
|
753eb18b71 | ||
|
|
17d8373739 | ||
|
|
d6ccc10244 | ||
|
|
3dccf82710 | ||
|
|
c7d8b67ccb | ||
|
|
b76043fa24 | ||
|
|
e28f4560d6 | ||
|
|
97d5156bbb | ||
|
|
40cf8f3f10 | ||
|
|
a325d07c6b | ||
|
|
69abd3afa2 | ||
|
|
cbdd6ee295 | ||
|
|
2c1abaaf32 | ||
|
|
8038ff74dd | ||
|
|
edcf3781b7 | ||
|
|
6ea053be36 | ||
|
|
67a62d7311 | ||
|
|
e17875dad7 | ||
|
|
b460de4e37 | ||
|
|
1ca336abe0 | ||
|
|
6e4a575864 | ||
|
|
d664adf000 | ||
|
|
41151593fd | ||
|
|
730b218eb5 | ||
|
|
ee99d40fb1 | ||
|
|
364036b9e4 | ||
|
|
27f68df6d7 | ||
|
|
02a7120413 | ||
|
|
d61140c349 | ||
|
|
ef91358c96 | ||
|
|
f2ab2a9759 | ||
|
|
0495dc10de | ||
|
|
9c41e7bb18 | ||
|
|
65ad9e6da0 | ||
|
|
0ef327a059 | ||
|
|
2a9e0a8f17 | ||
|
|
d6aac0b400 | ||
|
|
6d25f8d3bd | ||
|
|
eb45c6aefa | ||
|
|
79167a7f9d | ||
|
|
2a81f33340 | ||
|
|
4e5a68fa89 | ||
|
|
2d2f35c972 | ||
|
|
c606fe4480 | ||
|
|
fa26fad600 | ||
|
|
6da7f33437 | ||
|
|
6fcddfc7b9 | ||
|
|
ae59ffe73b | ||
|
|
94a2d414d3 | ||
|
|
c7f1be7c58 | ||
|
|
70d7ed7415 | ||
|
|
0351f8733d | ||
|
|
26b57e5475 | ||
|
|
2c66112d4d | ||
|
|
5327249f5e | ||
|
|
f300b640a2 | ||
|
|
6a062045bb | ||
|
|
22f69589c9 | ||
|
|
ca94368d0b | ||
|
|
05701c10d2 |
14
WorkFlow.API/Attributes/ApiKeyAuthAttribute.cs
Normal file
14
WorkFlow.API/Attributes/ApiKeyAuthAttribute.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Filters;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Attributes
|
||||||
|
{
|
||||||
|
//TODO: move APIKeyAuthAttribute to Core.API
|
||||||
|
public class APIKeyAuthAttribute : ServiceFilterAttribute
|
||||||
|
{
|
||||||
|
public APIKeyAuthAttribute()
|
||||||
|
: base(typeof(APIKeyAuthFilter))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
WorkFlow.API/Controllers/ConfigController.cs
Normal file
20
WorkFlow.API/Controllers/ConfigController.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using DigitalData.Core.API;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.DTO.Config;
|
||||||
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ConfigController : CRUDControllerBaseWithErrorHandling<IConfigService, ConfigCreateDto, ConfigDto, ConfigUpdateDto, Config, int>
|
||||||
|
{
|
||||||
|
public ConfigController(ILogger<ConfigController> logger, IConfigService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
96
WorkFlow.API/Controllers/ControllerExtensions.cs
Normal file
96
WorkFlow.API/Controllers/ControllerExtensions.cs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers
|
||||||
|
{
|
||||||
|
[APIKeyAuth]
|
||||||
|
public static class ControllerExtensions
|
||||||
|
{
|
||||||
|
public static bool TryGetUserId(this ControllerBase controller, out int? id)
|
||||||
|
{
|
||||||
|
var value = controller.User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
id = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(int.TryParse(value, out int id_int))
|
||||||
|
{
|
||||||
|
id = id_int;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryGetUsername(this ControllerBase controller, out string username)
|
||||||
|
{
|
||||||
|
var value = controller.User.FindFirstValue(ClaimTypes.Name);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
username = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
username = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryGetName(this ControllerBase controller, out string name)
|
||||||
|
{
|
||||||
|
var value = controller.User.FindFirstValue(ClaimTypes.Surname);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
name = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryGetPrename(this ControllerBase controller, out string prename)
|
||||||
|
{
|
||||||
|
var value = controller.User.FindFirstValue(ClaimTypes.GivenName);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
prename = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prename = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryGetEmail(this ControllerBase controller, out string email)
|
||||||
|
{
|
||||||
|
var value = controller.User.FindFirstValue(ClaimTypes.Email);
|
||||||
|
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
email = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
email = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
WorkFlow.API/Controllers/PlaceHolderAuthController.cs
Normal file
24
WorkFlow.API/Controllers/PlaceHolderAuthController.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using WorkFlow.API.Models;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
//TODO: implement up-to-date AuthController in UserManager
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/Auth")]
|
||||||
|
[ApiController]
|
||||||
|
[Tags("Auth")]
|
||||||
|
public class PlaceholderAuthController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateTokenViaBody([FromBody] Login login)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("check")]
|
||||||
|
[Authorize]
|
||||||
|
public IActionResult Check() => Ok();
|
||||||
|
}
|
||||||
20
WorkFlow.API/Controllers/ProfileController.cs
Normal file
20
WorkFlow.API/Controllers/ProfileController.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using DigitalData.Core.API;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.DTO.Profile;
|
||||||
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ProfileController : CRUDControllerBaseWithErrorHandling<IProfileService, ProfileCreateDto, ProfileDto, ProfileUpdateDto, Profile, int>
|
||||||
|
{
|
||||||
|
public ProfileController(ILogger<ProfileController> logger, IProfileService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
126
WorkFlow.API/Controllers/ProfileControlsTFController.cs
Normal file
126
WorkFlow.API/Controllers/ProfileControlsTFController.cs
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||||
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTFService, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, int>
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProfileControlsTFController> logger;
|
||||||
|
|
||||||
|
public ProfileControlsTFController(ILogger<ProfileControlsTFController> logger, IProfileControlsTFService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override Task<IActionResult> Update(ProfileControlsTFUpdateDto updateDto) => base.Update(updateDto);
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> GetAsync(
|
||||||
|
bool withProfile = true, bool withUser = false,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? id))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (id is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _service.ReadAsync(
|
||||||
|
withProfile: withProfile, withUser: withUser,
|
||||||
|
userId: id,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive)
|
||||||
|
.ThenAsync(
|
||||||
|
Success: pctf => pctf.Any() ? Ok(pctf) : NotFound(),
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
logger.LogNotice(ntc);
|
||||||
|
return NotFound();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public override async Task<IActionResult> Create([FromBody] ProfileControlsTFCreateDto createDto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? id))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (id is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createDto.UserId != id)
|
||||||
|
return Unauthorized();
|
||||||
|
|
||||||
|
return await base.Create(createDto);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public override async Task<IActionResult> Delete([FromRoute] int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? userId))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (userId is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _service.ReadByIdAsync(id).ThenAsync(
|
||||||
|
SuccessAsync: async pctf => pctf.UserId == userId ? await base.Delete(id) : Unauthorized(),
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(ntc);
|
||||||
|
return ntc.HasFlag(Flag.NotFound) ? NotFound() : StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
127
WorkFlow.API/Controllers/ProfileObjStateController.cs
Normal file
127
WorkFlow.API/Controllers/ProfileObjStateController.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.DTO.ProfileObjState;
|
||||||
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers
|
||||||
|
{
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ProfileObjStateController : CRUDControllerBaseWithErrorHandling<IProfileObjStateService, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, int>
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProfileObjStateController> logger;
|
||||||
|
|
||||||
|
public ProfileObjStateController(ILogger<ProfileObjStateController> logger, IProfileObjStateService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override Task<IActionResult> Update(ProfileObjStateUpdateDto updateDto) => base.Update(updateDto);
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> GetAsync(
|
||||||
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? id))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (id is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _service.ReadAsync(
|
||||||
|
withProfile: withProfile, withUser: withUser, withState,
|
||||||
|
userId: id,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive)
|
||||||
|
.ThenAsync(
|
||||||
|
Success: pctf => pctf.Any() ? Ok(pctf) : NotFound(),
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
logger.LogNotice(ntc);
|
||||||
|
return NotFound();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public override async Task<IActionResult> Create([FromBody] ProfileObjStateCreateDto createDto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? id))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (id is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createDto.UserId != id)
|
||||||
|
return Unauthorized();
|
||||||
|
|
||||||
|
return await base.Create(createDto);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public override async Task<IActionResult> Delete([FromRoute] int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? userId))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if (userId is null)
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _service.ReadByIdAsync(id).ThenAsync(
|
||||||
|
SuccessAsync: async pctf => pctf.UserId == userId ? await base.Delete(id) : Unauthorized(),
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(ntc);
|
||||||
|
return ntc.HasFlag(Flag.NotFound) ? NotFound() : StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
WorkFlow.API/Controllers/StateController.cs
Normal file
20
WorkFlow.API/Controllers/StateController.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using DigitalData.Core.API;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.DTO.State;
|
||||||
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class StateController : CRUDControllerBaseWithErrorHandling<IStateService, StateCreateDto, StateDto, StateUpdateDto, State, int>
|
||||||
|
{
|
||||||
|
public StateController(ILogger<StateController> logger, IStateService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
54
WorkFlow.API/Controllers/UserController.cs
Normal file
54
WorkFlow.API/Controllers/UserController.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WorkFlow.API.Attributes;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[APIKeyAuth]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class UserController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<UserController> logger;
|
||||||
|
private readonly IUserService userService;
|
||||||
|
|
||||||
|
public UserController(ILogger<UserController> logger, IUserService userService)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> GetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!this.TryGetUserId(out int? id))
|
||||||
|
{
|
||||||
|
logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
|
}
|
||||||
|
else if(id is int id_int)
|
||||||
|
return await userService.ReadByIdAsync(id_int).ThenAsync(
|
||||||
|
Success: Ok,
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
logger.LogNotice(ntc);
|
||||||
|
return NotFound();
|
||||||
|
});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "Invalid user ID.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
WorkFlow.API/Extensions/DIExtensions.cs
Normal file
22
WorkFlow.API/Extensions/DIExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using WorkFlow.API.Filters;
|
||||||
|
using WorkFlow.API.Models;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Extensions
|
||||||
|
{
|
||||||
|
public static class DIExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddAPIKeyAuth(this IServiceCollection services, Func<string?, bool> isValidKey, string headerName = "X-API-Key")
|
||||||
|
=> services.AddSingleton<APIKeyAuthFilter>(provider => new(isValidKey: isValidKey, headerName: headerName));
|
||||||
|
|
||||||
|
public static IServiceCollection AddAPIKeyAuth(this IServiceCollection services, APIKeyAuthOptions options, bool configureOptions = true)
|
||||||
|
{
|
||||||
|
if(configureOptions)
|
||||||
|
services.TryAddSingleton(Options.Create(options));
|
||||||
|
|
||||||
|
return services.AddAPIKeyAuth(isValidKey: key => options.Key is null || options.Key == key, headerName: options.HeaderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
WorkFlow.API/Filters/APIKeyAuthHeaderOpFilter.cs
Normal file
42
WorkFlow.API/Filters/APIKeyAuthHeaderOpFilter.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.OpenApi.Any;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
using WorkFlow.API.Models;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Filters;
|
||||||
|
|
||||||
|
public class APIKeyAuthHeaderOpFilter : IOperationFilter
|
||||||
|
{
|
||||||
|
private readonly APIKeyAuthOptions apiKeyAuthOptions;
|
||||||
|
private readonly IWebHostEnvironment environment;
|
||||||
|
|
||||||
|
public APIKeyAuthHeaderOpFilter(IOptions<APIKeyAuthOptions> options, IWebHostEnvironment environment)
|
||||||
|
{
|
||||||
|
this.environment = environment;
|
||||||
|
apiKeyAuthOptions = options.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
|
{
|
||||||
|
var param = new OpenApiParameter
|
||||||
|
{
|
||||||
|
Name = apiKeyAuthOptions.HeaderName,
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Required = true,
|
||||||
|
AllowEmptyValue = false,
|
||||||
|
Schema = new OpenApiSchema
|
||||||
|
{
|
||||||
|
Type = "string"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(environment.IsDevelopment())
|
||||||
|
param.Schema.Default = new OpenApiString(apiKeyAuthOptions.Key);
|
||||||
|
|
||||||
|
if (apiKeyAuthOptions.SwaggerDescription is not null)
|
||||||
|
param.Description = apiKeyAuthOptions.SwaggerDescription;
|
||||||
|
|
||||||
|
operation.Parameters.Add(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
WorkFlow.API/Filters/ApiKeyAuthFilter.cs
Normal file
22
WorkFlow.API/Filters/ApiKeyAuthFilter.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Filters;
|
||||||
|
|
||||||
|
public class APIKeyAuthFilter : IAuthorizationFilter
|
||||||
|
{
|
||||||
|
private readonly Func<string?, bool> isValidKey;
|
||||||
|
private readonly string headerName;
|
||||||
|
|
||||||
|
public APIKeyAuthFilter(Func<string?, bool> isValidKey, string headerName = "X-API-Key")
|
||||||
|
{
|
||||||
|
this.isValidKey = isValidKey;
|
||||||
|
this.headerName = headerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnAuthorization(AuthorizationFilterContext context)
|
||||||
|
{
|
||||||
|
if (!isValidKey(context.HttpContext.Request.Headers[headerName]))
|
||||||
|
context.Result = new UnauthorizedResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
10
WorkFlow.API/Jenkinsfile
vendored
Normal file
10
WorkFlow.API/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'dotnet build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
WorkFlow.API/LazyServiceProvider.cs
Normal file
18
WorkFlow.API/LazyServiceProvider.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace WorkFlow.API;
|
||||||
|
|
||||||
|
public class LazyServiceProvider : IServiceProvider
|
||||||
|
{
|
||||||
|
private Lazy<IServiceProvider>? _serviceProvider;
|
||||||
|
|
||||||
|
public Func<IServiceProvider> Factory
|
||||||
|
{
|
||||||
|
set => _serviceProvider = new(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object? GetService(Type serviceType)
|
||||||
|
{
|
||||||
|
if (_serviceProvider is null)
|
||||||
|
throw new InvalidOperationException("GetService cannot be called before _serviceProvider is set.");
|
||||||
|
return _serviceProvider.Value.GetService(serviceType);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
WorkFlow.API/Models/APIKeyAuthOptions.cs
Normal file
11
WorkFlow.API/Models/APIKeyAuthOptions.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace WorkFlow.API.Models
|
||||||
|
{
|
||||||
|
public class APIKeyAuthOptions
|
||||||
|
{
|
||||||
|
public string? Key { get; init; } = null;
|
||||||
|
|
||||||
|
public string HeaderName { get; init; } = "X-API-Key";
|
||||||
|
|
||||||
|
public string? SwaggerDescription { get; init; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
WorkFlow.API/Models/AuthTokenKeys.cs
Normal file
12
WorkFlow.API/Models/AuthTokenKeys.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace WorkFlow.API.Models;
|
||||||
|
|
||||||
|
public class AuthTokenKeys
|
||||||
|
{
|
||||||
|
public string Cookie { get; init; } = "AuthToken";
|
||||||
|
|
||||||
|
public string QueryString { get; init; } = "AuthToken";
|
||||||
|
|
||||||
|
public string Issuer { get; init; } = "auth.digitaldata.works";
|
||||||
|
|
||||||
|
public string Audience { get; init; } = "work-flow.digitaldata.works";
|
||||||
|
}
|
||||||
4
WorkFlow.API/Models/Login.cs
Normal file
4
WorkFlow.API/Models/Login.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
namespace WorkFlow.API.Models
|
||||||
|
{
|
||||||
|
public record Login(int? UserId, string? Username, string Password);
|
||||||
|
}
|
||||||
19
WorkFlow.API/Models/ModelExtensions.cs
Normal file
19
WorkFlow.API/Models/ModelExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Models
|
||||||
|
{
|
||||||
|
public static class ModelExtensions
|
||||||
|
{
|
||||||
|
public static List<Claim> ToClaimList(this UserReadDto user) => new()
|
||||||
|
{
|
||||||
|
new (ClaimTypes.NameIdentifier, user.Id.ToString()),
|
||||||
|
new (ClaimTypes.Name, user.Username),
|
||||||
|
new (ClaimTypes.Surname, user.Name ?? ""),
|
||||||
|
new (ClaimTypes.GivenName, user.Prename ?? ""),
|
||||||
|
new (ClaimTypes.Email, user.Email ?? "")
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Dictionary<string, object> ToClaimDictionary(this UserReadDto user) => user.ToClaimList().ToDictionary(claim => claim.Type, claim => (object) claim.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
161
WorkFlow.API/Program.cs
Normal file
161
WorkFlow.API/Program.cs
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
using WorkFlow.Application;
|
||||||
|
using DigitalData.UserManager.Application;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WorkFlow.Infrastructure;
|
||||||
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.Application;
|
||||||
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using WorkFlow.API.Models;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Web;
|
||||||
|
using WorkFlow.API.Extensions;
|
||||||
|
using WorkFlow.API.Filters;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using DigitalData.Auth.Client;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using WorkFlow.API;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using DigitalData.Core.Abstractions.Security;
|
||||||
|
|
||||||
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
|
logger.Info("Logging initialized.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
var config = builder.Configuration;
|
||||||
|
|
||||||
|
// Add NLogger
|
||||||
|
builder.Logging.ClearProviders();
|
||||||
|
builder.Host.UseNLog();
|
||||||
|
|
||||||
|
// Add services to the container
|
||||||
|
var cnn_str = config.GetConnectionString("Default") ?? throw new("Default connection string not found.");
|
||||||
|
builder.Services.AddDbContext<WFDBContext>(options => options.UseSqlServer(cnn_str).EnableDetailedErrors());
|
||||||
|
builder.Services.AddWorkFlow().AddUserManager<WFDBContext>();
|
||||||
|
builder.Services.AddCookieBasedLocalizer();
|
||||||
|
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
|
||||||
|
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()
|
||||||
|
{
|
||||||
|
Claims = user.ToClaimList().ToDictionary(claim => claim.Type, claim => claim.Value as object)
|
||||||
|
});
|
||||||
|
|
||||||
|
bool disableAPIKeyAuth = config.GetValue<bool>("DisableAPIKeyAuth") && builder.IsDevOrDiP();
|
||||||
|
if (disableAPIKeyAuth)
|
||||||
|
builder.Services.AddAPIKeyAuth(new APIKeyAuthOptions());
|
||||||
|
else
|
||||||
|
if (config.GetSection("APIKeyAuth").Get<APIKeyAuthOptions>() is APIKeyAuthOptions options)
|
||||||
|
builder.Services.AddAPIKeyAuth(options);
|
||||||
|
else
|
||||||
|
throw new("The API Key Authorization configuration is not available in the app settings, even though the app is not in development or DiP mode and API Key Authorization is not disabled.");
|
||||||
|
|
||||||
|
var lazyProvider = new LazyServiceProvider();
|
||||||
|
|
||||||
|
builder.Services.AddAuthHubClient(config.GetSection("AuthClientParams"));
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
|
var authTokenKeys = config.GetSection(nameof(AuthTokenKeys)).Get<AuthTokenKeys>() ?? new();
|
||||||
|
|
||||||
|
builder.Services.AddAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
})
|
||||||
|
.AddJwtBearer(opt =>
|
||||||
|
{
|
||||||
|
opt.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateIssuerSigningKey = true,
|
||||||
|
IssuerSigningKeyResolver = (token, securityToken, identifier, parameters) =>
|
||||||
|
{
|
||||||
|
var clientParams = lazyProvider.GetRequiredService<IOptions<ClientParams>>()?.Value;
|
||||||
|
var publicKey = clientParams!.PublicKeys.Get(authTokenKeys.Issuer, authTokenKeys.Audience);
|
||||||
|
return new List<SecurityKey>() { publicKey.SecurityKey };
|
||||||
|
},
|
||||||
|
ValidateIssuer = true,
|
||||||
|
ValidIssuer = authTokenKeys.Issuer,
|
||||||
|
ValidateAudience = true,
|
||||||
|
ValidAudience = authTokenKeys.Audience,
|
||||||
|
};
|
||||||
|
|
||||||
|
opt.Events = new JwtBearerEvents
|
||||||
|
{
|
||||||
|
OnMessageReceived = context =>
|
||||||
|
{
|
||||||
|
// if there is no token read related cookie or query string
|
||||||
|
if (context.Token is null) // if there is no token
|
||||||
|
{
|
||||||
|
if (context.Request.Cookies.TryGetValue(authTokenKeys.Cookie, out var cookieToken) && cookieToken is not null)
|
||||||
|
context.Token = cookieToken;
|
||||||
|
else if (context.Request.Query.TryGetValue(authTokenKeys.QueryString, out var queryStrToken))
|
||||||
|
context.Token = queryStrToken;
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen(setupAct =>
|
||||||
|
{
|
||||||
|
setupAct.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\"",
|
||||||
|
Name = "Authorization",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Type = SecuritySchemeType.Http,
|
||||||
|
Scheme = "Bearer"
|
||||||
|
});
|
||||||
|
|
||||||
|
setupAct.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||||
|
{
|
||||||
|
{
|
||||||
|
new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Reference = new OpenApiReference
|
||||||
|
{
|
||||||
|
Type = ReferenceType.SecurityScheme,
|
||||||
|
Id = "Bearer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Array.Empty<string>()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!disableAPIKeyAuth)
|
||||||
|
setupAct.OperationFilter<APIKeyAuthHeaderOpFilter>();
|
||||||
|
|
||||||
|
if (config.GetSection("OpenApiInfo").Get<OpenApiInfo>() is OpenApiInfo openApiInfo)
|
||||||
|
setupAct.SwaggerDoc(openApiInfo?.Version ?? "v1", openApiInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
lazyProvider.Factory = () => app.Services;
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.IsDevOrDiP() && app.Configuration.GetValue<bool>("EnableSwagger"))
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseCookieBasedLocalizer("de-DE");
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, "Stopped program because of exception.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<WebPublishMethod>Package</WebPublishMethod>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<ProjectGuid>4fb33592-ef0d-47c3-9cde-03b2ef12be00</ProjectGuid>
|
||||||
|
<DesktopBuildPackageLocation>P:\Install .Net\0 DD - Smart UP\workFLOW\API\net7\$(Version)\workFLOW.API.zip</DesktopBuildPackageLocation>
|
||||||
|
<PackageAsSingleFile>true</PackageAsSingleFile>
|
||||||
|
<DeployIisAppPath>WorkFlow.API</DeployIisAppPath>
|
||||||
|
<_TargetId>IISWebDeployPackage</_TargetId>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<WebPublishMethod>Package</WebPublishMethod>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<ProjectGuid>4fb33592-ef0d-47c3-9cde-03b2ef12be00</ProjectGuid>
|
||||||
|
<DesktopBuildPackageLocation>P:\Install .Net\0 DD - Smart UP\workFLOW\API\net8\$(Version)\workFLOW.API.zip</DesktopBuildPackageLocation>
|
||||||
|
<PackageAsSingleFile>true</PackageAsSingleFile>
|
||||||
|
<DeployIisAppPath>WorkFlow.API</DeployIisAppPath>
|
||||||
|
<_TargetId>IISWebDeployPackage</_TargetId>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
41
WorkFlow.API/Properties/launchSettings.json
Normal file
41
WorkFlow.API/Properties/launchSettings.json
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:56180",
|
||||||
|
"sslPort": 44397
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5130",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7120;http://localhost:5130",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": false,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
WorkFlow.API/WFKey.cs
Normal file
8
WorkFlow.API/WFKey.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace WorkFlow.API
|
||||||
|
{
|
||||||
|
public static class WFKey
|
||||||
|
{
|
||||||
|
public static readonly string WrongPassword = nameof(WrongPassword);
|
||||||
|
public static readonly string UserNotFoundOrWrongPassword = nameof(UserNotFoundOrWrongPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
WorkFlow.API/WorkFlow.API.csproj
Normal file
35
WorkFlow.API/WorkFlow.API.csproj
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<PackageId>WorkFlow.API</PackageId>
|
||||||
|
<Version>1.1.0</Version>
|
||||||
|
<Company>Digital Data GmbH</Company>
|
||||||
|
<Product>WorkFlow.API</Product>
|
||||||
|
<Title>WorkFlow.API</Title>
|
||||||
|
<AssemblyVersion>1.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>1.1.0</FileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfile - Copy.pubxml" />
|
||||||
|
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfileNet7.pubxml" />
|
||||||
|
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfileNet8.pubxml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DigitalData.Auth.Client" Version="1.3.3" />
|
||||||
|
<PackageReference Include="DigitalData.Core.API" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.20" />
|
||||||
|
<PackageReference Include="NLog" Version="5.3.4" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.14" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WorkFlow.Application\WorkFlow.Application.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
8
WorkFlow.API/appsettings.Development.json
Normal file
8
WorkFlow.API/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
91
WorkFlow.API/appsettings.json
Normal file
91
WorkFlow.API/appsettings.json
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"DiPMode": true,
|
||||||
|
"EnableSwagger": true,
|
||||||
|
"DisableAPIKeyAuth": false,
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"NLog": {
|
||||||
|
"throwConfigExceptions": true,
|
||||||
|
"variables": {
|
||||||
|
"logDirectory": "E:\\LogFiles\\Digital Data\\workFlow.API",
|
||||||
|
"logFileNamePrefix": "${shortdate}-workFlow.API"
|
||||||
|
},
|
||||||
|
"targets": {
|
||||||
|
"infoLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"errorLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"criticalLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Trace, Debug, Info, Warn, Error and *Fatal*
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"minLevel": "Info",
|
||||||
|
"maxLevel": "Warn",
|
||||||
|
"writeTo": "infoLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Error",
|
||||||
|
"writeTo": "errorLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Fatal",
|
||||||
|
"writeTo": "criticalLogs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||||
|
},
|
||||||
|
"DirectorySearchOptions": {
|
||||||
|
"ServerName": "DD-VMP01-DC01",
|
||||||
|
"Root": "DC=dd-gan,DC=local,DC=digitaldata,DC=works",
|
||||||
|
"UserCacheExpirationDays": 1,
|
||||||
|
"CustomSearchFilters": {
|
||||||
|
"User": "(&(objectClass=user)(sAMAccountName=*))",
|
||||||
|
"Group": "(&(objectClass=group) (samAccountName=*))"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"APIKeyAuth": {
|
||||||
|
"Key": "ULbcOUiAXAoCXPviyCGtObZUGnrCHNgDmtNbQNpq5MOhB0EFQn18dObdQ93INNy8xIcnOPMJfEHqOotllELVrJ2R5AjqOfQszT2j00w215GanD3UiJGwFhwmdoNFsmNj",
|
||||||
|
"HeaderName": "X-API-Key",
|
||||||
|
"SwaggerDescription": "Required header for API key authentication. Enter a valid API key."
|
||||||
|
},
|
||||||
|
"OpenApiInfo": {
|
||||||
|
"Title": "WorkFlow API",
|
||||||
|
"Contact": {
|
||||||
|
"Email": "info-flow@digitaldata.works",
|
||||||
|
"Name": "Digital Data GmbH",
|
||||||
|
"Url": "https://digitaldata.works/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AuthClientParams": {
|
||||||
|
"Url": "https://localhost:7192/auth-hub",
|
||||||
|
"PublicKeys": [
|
||||||
|
{
|
||||||
|
"Issuer": "auth.digitaldata.works",
|
||||||
|
"Audience": "work-flow.digitaldata.works",
|
||||||
|
"Content": "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3QCd7dH/xOUITFZbitMa/xnh8a0LyL6ZBvSRAwkI9ceplTRSHJXoM1oB+xtjWE1kOuHVLe941Tm03szS4+/rHIm0Ejva/KKlv7sPFAHE/pWuoPS303vOHgI4HAFcuwywA8CghUWzaaK5LU/Hl8srWwxBHv5hKIUjJFJygeAIENvFOZ1gFbB3MPEC99PiPOwAmfl4tMQUmSsFyspl/RWVi7bTv26ZE+m3KPcWppmvmYjXlSitxRaySxnfFvpca/qWfd/uUUg2KWKtpAwWVkqr0qD9v3TyKSgHoGDsrFpwSx8qufUJSinmZ1u/0iKl6TXeHubYS4C4SUSVjOWXymI2ZQIDAQAB-----END PUBLIC KEY-----"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"RetryDelay": "00:00:05"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IConfigService : ICRUDService<ConfigCreateDto, ConfigDto, ConfigUpdateDto, Config, int>
|
public interface IConfigService : ICRUDService<ConfigCreateDto, ConfigDto, Config, int>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IProfileControlsTFService : ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, int>
|
public interface IProfileControlsTFService : ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>
|
||||||
{
|
{
|
||||||
|
Task<DataResult<IEnumerable<ProfileControlsTFDto>>> ReadAsync(
|
||||||
|
bool withProfile = true, bool withUser = false,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using WorkFlow.Application.DTO.ProfileObjState;
|
using WorkFlow.Application.DTO.ProfileObjState;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IProfileObjStateService : ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, int>
|
public interface IProfileObjStateService : ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>
|
||||||
{
|
{
|
||||||
|
Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
|
||||||
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IProfileService : ICRUDService<ProfileCreateDto, ProfileDto, ProfileUpdateDto, Profile, int>
|
public interface IProfileService : ICRUDService<ProfileCreateDto, ProfileDto, Profile, int>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IStateService : ICRUDService<StateCreateDto, StateDto, StateUpdateDto, State, int>
|
public interface IStateService : ICRUDService<StateCreateDto, StateDto, State, int>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
||||||
{
|
{
|
||||||
public record ProfileControlsTFCreateDto(int Id,
|
public record ProfileControlsTFCreateDto(
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
int UsrId,
|
int UserId,
|
||||||
long ObjId,
|
long ObjId,
|
||||||
string ObjType,
|
string ObjType,
|
||||||
string AttrName,
|
string AttrName,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace WorkFlow.Application.DTO.ProfileControlsTF
|
|||||||
{
|
{
|
||||||
public record ProfileControlsTFDto(int Id,
|
public record ProfileControlsTFDto(int Id,
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
int UsrId,
|
int UserId,
|
||||||
long ObjId,
|
long ObjId,
|
||||||
string ObjType,
|
string ObjType,
|
||||||
string AttrName,
|
string AttrName,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public record ProfileObjStateCreateDto(
|
public record ProfileObjStateCreateDto(
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
int UsrId,
|
int UserId,
|
||||||
long ObjId,
|
long ObjId,
|
||||||
int StateId,
|
int StateId,
|
||||||
string? State2 = null,
|
string? State2 = null,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace WorkFlow.Application.DTO.ProfileObjState
|
|||||||
{
|
{
|
||||||
public record ProfileObjStateDto(int Id,
|
public record ProfileObjStateDto(int Id,
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
int UsrId,
|
int UserId,
|
||||||
long ObjId,
|
long ObjId,
|
||||||
int StateId,
|
int StateId,
|
||||||
string AddedWho,
|
string AddedWho,
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ using WorkFlow.Application.DTO.Config;
|
|||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services;
|
||||||
|
|
||||||
|
public class ConfigService : CRUDService<IConfigRepository, ConfigCreateDto, ConfigDto, Config, int>,
|
||||||
|
IConfigService, ICRUDService<ConfigCreateDto, ConfigDto, Config, int>
|
||||||
{
|
{
|
||||||
public class ConfigService(IConfigRepository repository, IMapper mapper)
|
public ConfigService(IConfigRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
: CRUDService<IConfigRepository, ConfigCreateDto, ConfigDto, ConfigUpdateDto, Config, int>(repository, mapper),
|
|
||||||
IConfigService, ICRUDService<ConfigCreateDto, ConfigDto, ConfigUpdateDto, Config, int>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,35 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Repositories;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services
|
||||||
{
|
{
|
||||||
public class ProfileControlsTFService(ProfileControlsTFRepository repository, IMapper mapper)
|
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>,
|
||||||
: CRUDService<ProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, int>(repository, mapper),
|
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>
|
||||||
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, int>
|
|
||||||
{
|
{
|
||||||
|
public ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<DataResult<IEnumerable<ProfileControlsTFDto>>> ReadAsync(
|
||||||
|
bool withProfile = true, bool withUser = false,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
{
|
||||||
|
var pctf_list = await _repository.ReadAsync(
|
||||||
|
isReadonly: true,
|
||||||
|
withProfile: withProfile, withUser: withUser,
|
||||||
|
userId: userId, username: username,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive);
|
||||||
|
|
||||||
|
var pctf_dto_list = _mapper.Map<IEnumerable<ProfileControlsTFDto>>(pctf_list);
|
||||||
|
|
||||||
|
return Result.Success(pctf_dto_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,34 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.ProfileObjState;
|
using WorkFlow.Application.DTO.ProfileObjState;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services;
|
||||||
|
|
||||||
|
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>,
|
||||||
|
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>
|
||||||
{
|
{
|
||||||
public class ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper)
|
public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
: CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, int>(repository, mapper),
|
|
||||||
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, int>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
|
||||||
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
{
|
||||||
|
var pos_list = await _repository.ReadAsync(
|
||||||
|
isReadonly: true,
|
||||||
|
withProfile: withProfile, withUser: withUser, withState: withState,
|
||||||
|
userId: userId, username: username,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive);
|
||||||
|
|
||||||
|
var post_dto_list = _mapper.Map<IEnumerable<ProfileObjStateDto>>(pos_list);
|
||||||
|
|
||||||
|
return Result.Success(post_dto_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,12 @@ using WorkFlow.Application.DTO.Profile;
|
|||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services;
|
||||||
|
|
||||||
|
public class ProfileService : CRUDService<IProfileRepository, ProfileCreateDto, ProfileDto, Profile, int>,
|
||||||
|
IProfileService, ICRUDService<ProfileCreateDto, ProfileDto, Profile, int>
|
||||||
{
|
{
|
||||||
public class ProfileService(IProfileRepository repository, AutoMapper.IMapper mapper)
|
public ProfileService(IProfileRepository repository, AutoMapper.IMapper mapper) : base(repository, mapper)
|
||||||
: CRUDService<IProfileRepository, ProfileCreateDto, ProfileDto, ProfileUpdateDto, Profile, int>(repository, mapper),
|
|
||||||
IProfileService, ICRUDService<ProfileCreateDto, ProfileDto, ProfileUpdateDto, Profile, int>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,12 @@ using WorkFlow.Application.DTO.State;
|
|||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services;
|
||||||
|
|
||||||
|
public class StateService : CRUDService<IStateRepository, StateCreateDto, StateDto, State, int>,
|
||||||
|
IStateService, ICRUDService<StateCreateDto, StateDto, State, int>
|
||||||
{
|
{
|
||||||
public class StateService(IStateRepository repository, IMapper mapper)
|
public StateService(IStateRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
: CRUDService<IStateRepository, StateCreateDto, StateDto, StateUpdateDto, State, int>(repository, mapper),
|
|
||||||
IStateService, ICRUDService<StateCreateDto, StateDto, StateUpdateDto, State, int>
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DigitalData.Core.Application" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.Application" Version="3.2.0" />
|
||||||
<PackageReference Include="UserManager.Application" Version="2.0.0" />
|
<PackageReference Include="UserManager.Application" Version="3.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace WorkFlow.Domain.Entities
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Column("USR_ID")]
|
[Column("USR_ID")]
|
||||||
public required int UsrId { get; init; }
|
public required int UserId { get; init; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Column("OBJ_ID")]
|
[Column("OBJ_ID")]
|
||||||
@@ -62,7 +62,7 @@ namespace WorkFlow.Domain.Entities
|
|||||||
[ForeignKey("ProfileId")]
|
[ForeignKey("ProfileId")]
|
||||||
public Profile? Profile { get; init; } = default;
|
public Profile? Profile { get; init; } = default;
|
||||||
|
|
||||||
[ForeignKey("UsrId")]
|
[ForeignKey("UserId")]
|
||||||
public User? User { get; set; } = default;
|
public User? User { get; set; } = default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ namespace WorkFlow.Domain.Entities
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Column("USR_ID")]
|
[Column("USR_ID")]
|
||||||
public required int UsrId { get; init; }
|
public required int UserId { get; init; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Column("OBJ_ID")]
|
[Column("OBJ_ID")]
|
||||||
@@ -48,7 +48,7 @@ namespace WorkFlow.Domain.Entities
|
|||||||
[ForeignKey("ProfileId")]
|
[ForeignKey("ProfileId")]
|
||||||
public Profile? Profile { get; init; } = null;
|
public Profile? Profile { get; init; } = null;
|
||||||
|
|
||||||
[ForeignKey("UsrId")]
|
[ForeignKey("UserId")]
|
||||||
public User? User { get; init; } = null;
|
public User? User { get; init; } = null;
|
||||||
|
|
||||||
[ForeignKey("StateId")]
|
[ForeignKey("StateId")]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="UserManager.Domain" Version="2.0.0" />
|
<PackageReference Include="UserManager.Domain" Version="3.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ namespace WorkFlow.Infrastructure.Contracts
|
|||||||
{
|
{
|
||||||
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, int>
|
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, int>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<ProfileControlsTF>> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = false, int? profileId = null, int? objId = null, bool? profileActive = null);
|
Task<IEnumerable<ProfileControlsTF>> ReadAsync(
|
||||||
|
bool isReadonly = true,
|
||||||
Task<ProfileControlsTF?> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = false, int? usrId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null);
|
bool withProfile = true, bool withUser = false,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,10 @@ namespace WorkFlow.Infrastructure.Contracts
|
|||||||
{
|
{
|
||||||
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, int>
|
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, int>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<ProfileObjState>> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? objId = null, bool? profileActive = null);
|
Task<IEnumerable<ProfileObjState>> ReadAsync(
|
||||||
|
bool isReadonly = true,
|
||||||
Task<ProfileObjState?> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = false, bool withState = true, int? usrId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null);
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,11 @@ using WorkFlow.Infrastructure.Contracts;
|
|||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories
|
||||||
{
|
{
|
||||||
public class ConfigRepository(WFDBContext dbContext) : CRUDRepository<Config, int, WFDBContext>(dbContext, dbContext.Configs), IConfigRepository, ICRUDRepository<Config, int>
|
//TODO: Make the db context type generic so that it can be used by other projects with different db contexts.
|
||||||
|
public class ConfigRepository : CRUDRepository<Config, int, WFDBContext>, IConfigRepository, ICRUDRepository<Config, int>
|
||||||
{
|
{
|
||||||
|
public ConfigRepository(WFDBContext dbContext) : base(dbContext, dbContext.Configs)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,15 @@ using WorkFlow.Infrastructure.Contracts;
|
|||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories
|
||||||
{
|
{
|
||||||
public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository<ProfileControlsTF, int, WFDBContext>(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, int, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
||||||
{
|
{
|
||||||
|
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override IQueryable<ProfileControlsTF> ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User);
|
protected override IQueryable<ProfileControlsTF> ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User);
|
||||||
|
|
||||||
protected IQueryable<ProfileControlsTF> Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, int? profileId = null, int? usrId = null, string? username = null, int? objId = null, bool? profileActive = null)
|
protected IQueryable<ProfileControlsTF> Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, int? profileId = null, int? userId = null, string? username = null, int? objId = null, bool? profileActive = null)
|
||||||
{
|
{
|
||||||
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
||||||
|
|
||||||
@@ -23,8 +27,8 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
if (profileId is not null)
|
if (profileId is not null)
|
||||||
query = query.Where(pctf => pctf.ProfileId == profileId);
|
query = query.Where(pctf => pctf.ProfileId == profileId);
|
||||||
|
|
||||||
if (usrId is not null)
|
if (userId is not null)
|
||||||
query = query.Where(pctf => pctf.UsrId == usrId);
|
query = query.Where(pctf => pctf.UserId == userId);
|
||||||
|
|
||||||
if (username is null)
|
if (username is null)
|
||||||
query = query.Where(pctf => pctf.User!.Username == username);
|
query = query.Where(pctf => pctf.User!.Username == username);
|
||||||
@@ -38,11 +42,16 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ProfileControlsTF>> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = true, int? profileId = null, int? objId = null, bool? profileActive = null)
|
public async Task<IEnumerable<ProfileControlsTF>> ReadAsync(
|
||||||
=> await Read(isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, profileId: profileId, objId: objId, profileActive: profileActive).ToListAsync();
|
bool isReadonly = true,
|
||||||
|
bool withProfile = true, bool withUser = true,
|
||||||
public async Task<ProfileControlsTF?> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = false, int? usrId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null)
|
int? userId = null, string? username = null,
|
||||||
=> await Read(isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, usrId: usrId, username: username, profileId: profileId, objId: objId, profileActive: profileActive)
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
.FirstOrDefaultAsync();
|
=> await Read(
|
||||||
|
isReadonly: isReadonly,
|
||||||
|
withProfile: withProfile, withUser: withUser,
|
||||||
|
userId: userId, username: username,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive)
|
||||||
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,51 +4,59 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, int, WFDBContext>, IProfileObjStateRepository, ICRUDRepository<ProfileObjState, int>
|
||||||
{
|
{
|
||||||
public class ProfileObjStateRepository(WFDBContext dbContext) : CRUDRepository<ProfileObjState, int, WFDBContext>(dbContext, dbContext.ProfileObjStates), IProfileObjStateRepository, ICRUDRepository<ProfileObjState, int>
|
public ProfileObjStateRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileObjStates)
|
||||||
{
|
{
|
||||||
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
|
|
||||||
|
|
||||||
protected IQueryable<ProfileObjState> Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? usrId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null)
|
|
||||||
{
|
|
||||||
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
|
||||||
|
|
||||||
if (withProfile)
|
|
||||||
query = query.Include(pctf => pctf.Profile);
|
|
||||||
|
|
||||||
if (withUser)
|
|
||||||
query = query.Include(pctf => pctf.User);
|
|
||||||
|
|
||||||
if (withState)
|
|
||||||
query = query.Include(pctf => pctf.State);
|
|
||||||
|
|
||||||
if (profileId is not null)
|
|
||||||
query = query.Where(pctf => pctf.ProfileId == profileId);
|
|
||||||
|
|
||||||
if (usrId is not null)
|
|
||||||
query = query.Where(pctf => pctf.UsrId == usrId);
|
|
||||||
|
|
||||||
if (username is null)
|
|
||||||
query = query.Where(pctf => pctf.User!.Username == username);
|
|
||||||
|
|
||||||
if (stateId is null)
|
|
||||||
query = query.Where(pctf => pctf.State!.Id == stateId);
|
|
||||||
|
|
||||||
if (objId is not null)
|
|
||||||
query = query.Where(pctf => pctf.ObjId == objId);
|
|
||||||
|
|
||||||
if (profileActive is not null)
|
|
||||||
query = query.Where(pctf => pctf.Profile!.Active == profileActive);
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<ProfileObjState>> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? objId = null, bool? profileActive = null)
|
|
||||||
=> await Read(isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, withState: withState, profileId: profileId, objId: objId, profileActive: profileActive).ToListAsync();
|
|
||||||
|
|
||||||
public async Task<ProfileObjState?> ReadAsync(bool isReadonly = true, bool withProfile = true, bool withUser = false, bool withState = true, int? usrId = null, string? username = null, int? profileId = null, int? objId = null, bool? profileActive = null)
|
|
||||||
=> await Read(isReadonly: isReadonly, withProfile: withProfile, withUser: withUser, withState: withState, usrId: usrId, username: username, profileId: profileId, objId: objId, profileActive: profileActive)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
|
||||||
|
|
||||||
|
protected IQueryable<ProfileObjState> Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? userId = null, string? username = null, int? stateId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
{
|
||||||
|
var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable();
|
||||||
|
|
||||||
|
if (withProfile)
|
||||||
|
query = query.Include(pctf => pctf.Profile);
|
||||||
|
|
||||||
|
if (withUser)
|
||||||
|
query = query.Include(pctf => pctf.User);
|
||||||
|
|
||||||
|
if (withState)
|
||||||
|
query = query.Include(pctf => pctf.State);
|
||||||
|
|
||||||
|
if (profileId is not null)
|
||||||
|
query = query.Where(pctf => pctf.ProfileId == profileId);
|
||||||
|
|
||||||
|
if (userId is not null)
|
||||||
|
query = query.Where(pctf => pctf.UserId == userId);
|
||||||
|
|
||||||
|
if (username is null)
|
||||||
|
query = query.Where(pctf => pctf.User!.Username == username);
|
||||||
|
|
||||||
|
if (stateId is null)
|
||||||
|
query = query.Where(pctf => pctf.State!.Id == stateId);
|
||||||
|
|
||||||
|
if (objId is not null)
|
||||||
|
query = query.Where(pctf => pctf.ObjId == objId);
|
||||||
|
|
||||||
|
if (profileActive is not null)
|
||||||
|
query = query.Where(pctf => pctf.Profile!.Active == profileActive);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ProfileObjState>> ReadAsync(
|
||||||
|
bool isReadonly = true,
|
||||||
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
int? userId = null, string? username = null,
|
||||||
|
int? profileId = null, int? objId = null, bool? profileActive = null)
|
||||||
|
=> await Read(
|
||||||
|
isReadonly: isReadonly,
|
||||||
|
withProfile: withProfile, withUser: withUser, withState: withState,
|
||||||
|
userId: userId, username: username,
|
||||||
|
profileId: profileId, objId: objId, profileActive: profileActive)
|
||||||
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,11 @@ using DigitalData.Core.Infrastructure;
|
|||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class ProfileRepository : CRUDRepository<Profile, int, WFDBContext>, IProfileRepository, ICRUDRepository<Profile, int>
|
||||||
{
|
{
|
||||||
public class ProfileRepository(WFDBContext dbContext) : CRUDRepository<Profile, int, WFDBContext>(dbContext, dbContext.Profiles), IProfileRepository, ICRUDRepository<Profile, int>
|
public ProfileRepository(WFDBContext dbContext) : base(dbContext, dbContext.Profiles)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,12 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
|
||||||
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class StateRepository : CRUDRepository<State, int, WFDBContext>, IStateRepository, ICRUDRepository<State, int>
|
||||||
{
|
{
|
||||||
public class StateRepository(WFDBContext dbContext) : CRUDRepository<State, int, WFDBContext>(dbContext, dbContext.States), IStateRepository, ICRUDRepository<State, int>
|
public StateRepository(WFDBContext dbContext) : base(dbContext, dbContext.States)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,46 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
|
using DigitalData.UserManager.Infrastructure;
|
||||||
|
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure
|
namespace WorkFlow.Infrastructure;
|
||||||
|
|
||||||
|
public class WFDBContext : DbContext, IUserManagerDbContext
|
||||||
{
|
{
|
||||||
public class WFDBContext(DbContextOptions options) : DbContext(options)
|
public DbSet<Config> Configs { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ProfileControlsTF> ProfileControlsTFs { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Profile> Profiles { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ProfileObjState> ProfileObjStates { get; set; }
|
||||||
|
|
||||||
|
public DbSet<State> States { get; set; }
|
||||||
|
|
||||||
|
public DbSet<GroupOfUser> GroupOfUsers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Group> Groups { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ModuleOfUser> ModuleOfUsers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Module> Modules { get; set; }
|
||||||
|
|
||||||
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public DbSet<UserRep> UserReps { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ClientUser> ClientUsers { get; set; }
|
||||||
|
|
||||||
|
public WFDBContext(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
public DbSet<Config> Configs { get; set; }
|
}
|
||||||
|
|
||||||
public DbSet<ProfileControlsTF> ProfileControlsTFs { get; set; }
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
//configure model builder for user manager tables
|
||||||
|
modelBuilder.ConfigureUserManager();
|
||||||
|
|
||||||
public DbSet<Profile> Profiles { get; set; }
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
public DbSet<ProfileObjState> ProfileObjStates { get; set; }
|
|
||||||
|
|
||||||
public DbSet<State> States { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.0" />
|
||||||
|
<PackageReference Include="UserManager.Infrastructure" Version="3.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkFlow.Infrastructure", "
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.Application", "WorkFlow.Application\WorkFlow.Application.csproj", "{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.Application", "WorkFlow.Application\WorkFlow.Application.csproj", "{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkFlow.API", "WorkFlow.API\WorkFlow.API.csproj", "{4FB33592-EF0D-47C3-9CDE-03B2EF12BE00}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -27,6 +29,10 @@ Global
|
|||||||
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5700B5DD-D17E-4E17-ADE5-48C95A0CC364}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4FB33592-EF0D-47C3-9CDE-03B2EF12BE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4FB33592-EF0D-47C3-9CDE-03B2EF12BE00}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4FB33592-EF0D-47C3-9CDE-03B2EF12BE00}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4FB33592-EF0D-47C3-9CDE-03B2EF12BE00}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user