refactor(Profil): dto in den Ordner DTO verschieben.
- Ordner DTO in Dto umbenennen
This commit is contained in:
parent
6c0f39e3ed
commit
904536bd09
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WorkFlow.API.Attributes;
|
using WorkFlow.API.Attributes;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.Config;
|
using WorkFlow.Application.Dto.Config;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.API.Controllers;
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WorkFlow.API.Attributes;
|
using WorkFlow.API.Attributes;
|
||||||
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;
|
||||||
|
|
||||||
namespace WorkFlow.API.Controllers;
|
namespace WorkFlow.API.Controllers;
|
||||||
@ -13,53 +13,20 @@ namespace WorkFlow.API.Controllers;
|
|||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTFService, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, int>
|
public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTFService, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTFUpdateDto, ProfileControlsTF, long>
|
||||||
{
|
{
|
||||||
private readonly ILogger<ProfileControlsTFController> logger;
|
|
||||||
|
|
||||||
public ProfileControlsTFController(ILogger<ProfileControlsTFController> logger, IProfileControlsTFService service) : base(logger, service)
|
public ProfileControlsTFController(ILogger<ProfileControlsTFController> logger, IProfileControlsTFService service) : base(logger, service)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
|
[HttpPut]
|
||||||
public override Task<IActionResult> Update(ProfileControlsTFUpdateDto updateDto) => base.Update(updateDto);
|
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 (!User.TryGetUserId(out var id))
|
|
||||||
{
|
|
||||||
logger.LogError("Authorization failed: User ID claim not found.");
|
|
||||||
return Unauthorized("Failed to retrieve user identity.");
|
|
||||||
}
|
|
||||||
|
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public override async Task<IActionResult> Create([FromBody] ProfileControlsTFCreateDto createDto)
|
public override async Task<IActionResult> Create([FromBody] ProfileControlsTFCreateDto createDto)
|
||||||
@ -68,7 +35,7 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
|||||||
{
|
{
|
||||||
if (!User.TryGetUserId(out var id))
|
if (!User.TryGetUserId(out var id))
|
||||||
{
|
{
|
||||||
logger.LogError("Authorization failed: User ID claim not found.");
|
_logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,20 +46,20 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
_logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public override async Task<IActionResult> Delete([FromRoute] int id)
|
public override async Task<IActionResult> Delete([FromRoute] long id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!User.TryGetUserId(out var userId))
|
if (!User.TryGetUserId(out var userId))
|
||||||
{
|
{
|
||||||
logger.LogError("Authorization failed: User ID claim not found.");
|
_logger.LogError("Authorization failed: User ID claim not found.");
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to retrieve user identity.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +73,7 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
_logger.LogError(ex, "An unexpected error occurred while processing the request: {Message}", ex.Message);
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
return StatusCode(StatusCodes.Status500InternalServerError, "An internal server error occurred.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WorkFlow.API.Attributes;
|
using WorkFlow.API.Attributes;
|
||||||
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;
|
||||||
|
|
||||||
namespace WorkFlow.API.Controllers
|
namespace WorkFlow.API.Controllers
|
||||||
@ -13,7 +13,7 @@ namespace WorkFlow.API.Controllers
|
|||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ProfileObjStateController : CRUDControllerBaseWithErrorHandling<IProfileObjStateService, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, int>
|
public class ProfileObjStateController : CRUDControllerBaseWithErrorHandling<IProfileObjStateService, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjStateUpdateDto, ProfileObjState, long>
|
||||||
{
|
{
|
||||||
private readonly ILogger<ProfileObjStateController> logger;
|
private readonly ILogger<ProfileObjStateController> logger;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ namespace WorkFlow.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public override async Task<IActionResult> Delete([FromRoute] int id)
|
public override async Task<IActionResult> Delete([FromRoute] long id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WorkFlow.API.Attributes;
|
using WorkFlow.API.Attributes;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.State;
|
using WorkFlow.Application.Dto.State;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.API.Controllers;
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using WorkFlow.Application.DTO.Config;
|
using WorkFlow.Application.Dto.Config;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
|
|||||||
@ -1,15 +1,9 @@
|
|||||||
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, ProfileControlsTF, long>
|
||||||
{
|
{
|
||||||
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,11 +1,11 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Core.DTO;
|
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, ProfileObjState, int>
|
public interface IProfileObjStateService : ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>
|
||||||
{
|
{
|
||||||
Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
|
Task<DataResult<IEnumerable<ProfileObjStateDto>>> ReadAsync(
|
||||||
bool withProfile = true, bool withUser = true, bool withState = true,
|
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using WorkFlow.Application.DTO.State;
|
using WorkFlow.Application.Dto.State;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Contracts
|
namespace WorkFlow.Application.Contracts
|
||||||
|
|||||||
@ -3,11 +3,6 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts.Repositories;
|
namespace WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, int>
|
public interface IProfileControlsTFRepository : ICRUDRepository<ProfileControlsTF, long>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<ProfileControlsTF>> ReadAsync(
|
|
||||||
bool isReadonly = true,
|
|
||||||
bool withProfile = true, bool withUser = false,
|
|
||||||
int? userId = null, string? username = null,
|
|
||||||
int? profileId = null, int? objId = null, bool? profileActive = null);
|
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts.Repositories;
|
namespace WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, int>
|
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, long>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<ProfileObjState>> ReadAsync(
|
Task<IEnumerable<ProfileObjState>> ReadAsync(
|
||||||
bool isReadonly = true,
|
bool isReadonly = true,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO
|
namespace WorkFlow.Application.Dto
|
||||||
{
|
{
|
||||||
public record BaseCreateDto
|
public record BaseCreateDto
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO
|
namespace WorkFlow.Application.Dto
|
||||||
{
|
{
|
||||||
public record BaseUpdateDto : IUnique<int>
|
public record BaseUpdateDto : IUnique<int>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.Config
|
namespace WorkFlow.Application.Dto.Config
|
||||||
{
|
{
|
||||||
public record ConfigCreateDto(string Title, string String);
|
public record ConfigCreateDto(string Title, string String);
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.Config
|
namespace WorkFlow.Application.Dto.Config
|
||||||
{
|
{
|
||||||
public record ConfigDto(int Id,
|
public record ConfigDto(int Id,
|
||||||
string Title,
|
string Title,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.Config
|
namespace WorkFlow.Application.Dto.Config
|
||||||
{
|
{
|
||||||
public record ConfigUpdateDto(string Title, string String) : BaseUpdateDto;
|
public record ConfigUpdateDto(string Title, string String) : BaseUpdateDto;
|
||||||
}
|
}
|
||||||
@ -1,4 +0,0 @@
|
|||||||
namespace WorkFlow.Application.DTO.Profile
|
|
||||||
{
|
|
||||||
public record ProfileCreateDto(string IntlName, int ExtId1, bool Active, byte TypeId) : BaseCreateDto;
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
namespace WorkFlow.Application.DTO.Profile
|
|
||||||
{
|
|
||||||
public record ProfileUpdateDto(string IntlName, int ExtId1, bool Active, byte TypeId) : BaseUpdateDto;
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
namespace WorkFlow.Application.Dto.ProfileControlsTF
|
||||||
{
|
{
|
||||||
public record ProfileControlsTFCreateDto(
|
public record ProfileControlsTFCreateDto(
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using DigitalData.UserManager.Application.DTOs.User;
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
using WorkFlow.Application.DTO.Profile;
|
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
namespace WorkFlow.Application.Dto.ProfileControlsTF
|
||||||
{
|
{
|
||||||
public record ProfileControlsTFDto(int Id,
|
public record ProfileControlsTFDto(int Id,
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
namespace WorkFlow.Application.Dto.ProfileControlsTF
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record ProfileControlsTFUpdateDto(int Id) : IUnique<int>;
|
public record ProfileControlsTFUpdateDto(long Id) : IUnique<long>;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.ProfileObjState
|
namespace WorkFlow.Application.Dto.ProfileObjState
|
||||||
{
|
{
|
||||||
public record ProfileObjStateCreateDto(
|
public record ProfileObjStateCreateDto(
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
using DigitalData.UserManager.Application.DTOs.User;
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
using WorkFlow.Application.DTO.Profile;
|
using WorkFlow.Application.Dto.State;
|
||||||
using WorkFlow.Application.DTO.State;
|
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO.ProfileObjState
|
namespace WorkFlow.Application.Dto.ProfileObjState
|
||||||
{
|
{
|
||||||
public record ProfileObjStateDto(int Id,
|
public record ProfileObjStateDto(int Id,
|
||||||
int ProfileId,
|
int ProfileId,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO.ProfileObjState
|
namespace WorkFlow.Application.Dto.ProfileObjState
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record ProfileObjStateUpdateDto(int Id) : IUnique<int>;
|
public record ProfileObjStateUpdateDto(long Id) : IUnique<long>;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.State
|
namespace WorkFlow.Application.Dto.State
|
||||||
{
|
{
|
||||||
public record StateCreateDto(string IntlState) : BaseCreateDto;
|
public record StateCreateDto(string IntlState) : BaseCreateDto;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace WorkFlow.Application.DTO.State
|
namespace WorkFlow.Application.Dto.State
|
||||||
{
|
{
|
||||||
public record StateDto(int Id, string IntlState, string AddedWho, DateTime AddedWhen);
|
public record StateDto(int Id, string IntlState, string AddedWho, DateTime AddedWhen);
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
|
|
||||||
namespace WorkFlow.Application.DTO.State
|
namespace WorkFlow.Application.Dto.State
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
||||||
|
|||||||
25
src/WorkFlow.Application/Dto/ProfileDto.cs
Normal file
25
src/WorkFlow.Application/Dto/ProfileDto.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using WorkFlow.Application.Buttons;
|
||||||
|
using WorkFlow.Application.Objects;
|
||||||
|
|
||||||
|
namespace WorkFlow.Application.Dto;
|
||||||
|
|
||||||
|
public class ProfileDto
|
||||||
|
{
|
||||||
|
public int? Id { get; init; }
|
||||||
|
|
||||||
|
public byte? TypeId { get; init; }
|
||||||
|
|
||||||
|
public string? Caption { get; init; }
|
||||||
|
|
||||||
|
public string? Subtitle { get; init; }
|
||||||
|
|
||||||
|
public int? CountObj { get; init; }
|
||||||
|
|
||||||
|
public string? ForeColor { get; init; }
|
||||||
|
|
||||||
|
public string? BackColor { get; init; }
|
||||||
|
|
||||||
|
public IEnumerable<ObjectDto> Objects { get; init; } = Array.Empty<ObjectDto>();
|
||||||
|
|
||||||
|
public IEnumerable<ButtonDto>? Buttons { get; set; } = Array.Empty<ButtonDto>();
|
||||||
|
}
|
||||||
@ -1,47 +1,42 @@
|
|||||||
using AutoMapper;
|
using WorkFlow.Application.Buttons;
|
||||||
using WorkFlow.Application.Buttons;
|
using WorkFlow.Application.Dto;
|
||||||
using WorkFlow.Application.DTO.Config;
|
using WorkFlow.Application.Dto.Config;
|
||||||
using WorkFlow.Application.DTO.Profile;
|
using WorkFlow.Application.Dto.ProfileControlsTF;
|
||||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
using WorkFlow.Application.Dto.ProfileObjState;
|
||||||
using WorkFlow.Application.DTO.ProfileObjState;
|
using WorkFlow.Application.Dto.State;
|
||||||
using WorkFlow.Application.DTO.State;
|
|
||||||
using WorkFlow.Application.Objects;
|
using WorkFlow.Application.Objects;
|
||||||
using WorkFlow.Application.Profiles;
|
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Application
|
namespace WorkFlow.Application;
|
||||||
|
|
||||||
|
public class MappingProfile : AutoMapper.Profile
|
||||||
{
|
{
|
||||||
public class MappingProfile : AutoMapper.Profile
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
public MappingProfile()
|
// Mapping entity to DTO
|
||||||
{
|
CreateMap<Config, ConfigDto>();
|
||||||
// Mapping entity to DTO
|
CreateMap<Profile, ProfileDto>();
|
||||||
CreateMap<Config, ConfigDto>();
|
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
|
||||||
CreateMap<Domain.Entities.Profile, ProfileDto>();
|
CreateMap<ProfileObjState, ProfileObjStateDto>();
|
||||||
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
|
CreateMap<State, StateDto>();
|
||||||
CreateMap<ProfileObjState, ProfileObjStateDto>();
|
CreateMap<Button, ButtonDto>();
|
||||||
CreateMap<State, StateDto>();
|
CreateMap<ProfileObject, ObjectDto>()
|
||||||
CreateMap<Button, ButtonDto>();
|
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src =>
|
||||||
CreateMap<ProfileObject, ObjectDto>()
|
new[] { src.Headline1, src.Headline2 }))
|
||||||
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src =>
|
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src =>
|
||||||
new[] { src.Headline1, src.Headline2 }))
|
new[] { src.Subline1, src.Subline2 }));
|
||||||
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src =>
|
|
||||||
new[] { src.Subline1, src.Subline2 }));
|
|
||||||
|
|
||||||
|
|
||||||
// Mapping create-DTO to entity
|
// Mapping create-DTO to entity
|
||||||
CreateMap<ConfigCreateDto, Config>();
|
CreateMap<ConfigCreateDto, Config>();
|
||||||
CreateMap<ProfileCreateDto, Domain.Entities.Profile>();
|
CreateMap<ProfileControlsTFCreateDto, ProfileControlsTF>();
|
||||||
CreateMap<ProfileControlsTFCreateDto, ProfileControlsTF>();
|
CreateMap<ProfileObjStateCreateDto, ProfileObjState>();
|
||||||
CreateMap<ProfileObjStateCreateDto, ProfileObjState>();
|
CreateMap<StateCreateDto, State>();
|
||||||
CreateMap<StateCreateDto, State>();
|
|
||||||
|
|
||||||
// Mapping update-DTO to entity
|
// Mapping update-DTO to entity
|
||||||
CreateMap<ConfigUpdateDto, Config>();
|
CreateMap<ConfigUpdateDto, Config>();
|
||||||
CreateMap<ProfileUpdateDto, Domain.Entities.Profile>();
|
CreateMap<ProfileControlsTFUpdateDto, ProfileControlsTF>();
|
||||||
CreateMap<ProfileControlsTFUpdateDto, ProfileControlsTF>();
|
CreateMap<ProfileObjStateUpdateDto, ProfileObjState>();
|
||||||
CreateMap<ProfileObjStateUpdateDto, ProfileObjState>();
|
CreateMap<StateUpdateDto, State>();
|
||||||
CreateMap<StateUpdateDto, State>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,42 +2,21 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using WorkFlow.Application.Buttons;
|
using WorkFlow.Application.Buttons;
|
||||||
using WorkFlow.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
using WorkFlow.Application.Objects;
|
using WorkFlow.Application.Dto;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Profiles;
|
namespace WorkFlow.Application.Profiles;
|
||||||
|
|
||||||
public class ProfileDto
|
|
||||||
{
|
|
||||||
public int? Id { get; init; }
|
|
||||||
|
|
||||||
public byte? TypeId { get; init; }
|
|
||||||
|
|
||||||
public string? Caption { get; init; }
|
|
||||||
|
|
||||||
public string? Subtitle { get; init; }
|
|
||||||
|
|
||||||
public int? CountObj { get; init; }
|
|
||||||
|
|
||||||
public string? ForeColor { get; init; }
|
|
||||||
|
|
||||||
public string? BackColor { get; init; }
|
|
||||||
|
|
||||||
public IEnumerable<ObjectDto> Objects { get; init; } = Array.Empty<ObjectDto>();
|
|
||||||
|
|
||||||
public IEnumerable<ButtonDto>? Buttons { get; set; } = Array.Empty<ButtonDto>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to read a user profile by their user ID.
|
/// Represents a request to read a user profile by their user ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="UserId">The ID of the user whose profile is being requested.</param>
|
/// <param name="UserId">The ID of the user whose profile is being requested.</param>
|
||||||
public record ReadProfileRequest(int UserId, bool IncludeObject = true) : IRequest<ProfileDto?>;
|
public record ReadProfileQuery(int UserId, bool IncludeObject = true) : IRequest<ProfileDto?>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <see cref="ReadProfileRequest"/> request by retrieving the user profile
|
/// Handles the <see cref="ReadProfileQuery"/> request by retrieving the user profile
|
||||||
/// from the data store using the <see cref="IProfileRepository"/>.
|
/// from the data store using the <see cref="IProfileRepository"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ReadProfileHandler : IRequestHandler<ReadProfileRequest, ProfileDto?>
|
public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto?>
|
||||||
{
|
{
|
||||||
private readonly IProfileRepository _profileRepository;
|
private readonly IProfileRepository _profileRepository;
|
||||||
|
|
||||||
@ -61,13 +40,13 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileRequest, ProfileDto
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the <see cref="ReadProfileRequest"/> request by retrieving the profile
|
/// Handles the <see cref="ReadProfileQuery"/> request by retrieving the profile
|
||||||
/// corresponding to the specified user ID.
|
/// corresponding to the specified user ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request containing the user ID.</param>
|
/// <param name="request">The request containing the user ID.</param>
|
||||||
/// <param name="cancel">A cancellation token for the operation.</param>
|
/// <param name="cancel">A cancellation token for the operation.</param>
|
||||||
/// <returns>The user profile if found; otherwise, <c>null</c>.</returns>
|
/// <returns>The user profile if found; otherwise, <c>null</c>.</returns>
|
||||||
public async Task<ProfileDto?> Handle(ReadProfileRequest request, CancellationToken cancel = default)
|
public async Task<ProfileDto?> Handle(ReadProfileQuery request, CancellationToken cancel = default)
|
||||||
{
|
{
|
||||||
var profile = await _profileRepository.ReadAsync(request.UserId, cancel);
|
var profile = await _profileRepository.ReadAsync(request.UserId, cancel);
|
||||||
if (request.IncludeObject && profile?.Id is int profileId)
|
if (request.IncludeObject && profile?.Id is int profileId)
|
||||||
@ -85,8 +64,8 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileRequest, ProfileDto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ReadProfileExtensions
|
public static class ReadProfileQueryExtensions
|
||||||
{
|
{
|
||||||
public static Task<ProfileDto?> ReadProfileAsync(this IMediator mediator, int userId, bool includeObject = true)
|
public static Task<ProfileDto?> ReadProfileAsync(this IMediator mediator, int userId, bool includeObject = true)
|
||||||
=> mediator.Send(new ReadProfileRequest(UserId: userId, IncludeObject: includeObject));
|
=> mediator.Send(new ReadProfileQuery(UserId: userId, IncludeObject: includeObject));
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.Config;
|
using WorkFlow.Application.Dto.Config;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
|||||||
@ -3,33 +3,22 @@ using DigitalData.Core.Abstractions.Application;
|
|||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using DigitalData.Core.DTO;
|
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.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services
|
namespace WorkFlow.Application.Services
|
||||||
{
|
{
|
||||||
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>,
|
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>,
|
||||||
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>
|
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>
|
||||||
{
|
{
|
||||||
public ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) : base(repository, mapper)
|
public ProfileControlsTFService(IProfileControlsTFRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<ProfileControlsTFDto>>> ReadAsync(
|
public 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)
|
||||||
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(
|
throw new NotImplementedException();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,14 +3,14 @@ using DigitalData.Core.Abstractions.Application;
|
|||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using DigitalData.Core.DTO;
|
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.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace WorkFlow.Application.Services;
|
namespace WorkFlow.Application.Services;
|
||||||
|
|
||||||
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>,
|
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>,
|
||||||
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>
|
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>
|
||||||
{
|
{
|
||||||
public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper)
|
public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.State;
|
using WorkFlow.Application.Dto.State;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using DigitalData.Core.Abstractions;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace WorkFlow.Domain.Entities;
|
namespace WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
[Table("TBMWF_PROF_CONTROLS_TF", Schema = "dbo")]
|
[Table("TBMWF_PROF_CONTROLS_TF", Schema = "dbo")]
|
||||||
public class ProfileControlsTF
|
public class ProfileControlsTF : IUnique<long>
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[Column("GUID", TypeName = "bigint")]
|
[Column("GUID", TypeName = "bigint")]
|
||||||
|
|||||||
@ -6,48 +6,9 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories;
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, int, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, long, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, long>
|
||||||
{
|
{
|
||||||
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
|
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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? userId = null, string? username = null, int? objId = 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 (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 (objId is not null)
|
|
||||||
query = query.Where(pctf => pctf.ObjId == objId);
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<ProfileControlsTF>> ReadAsync(
|
|
||||||
bool isReadonly = true,
|
|
||||||
bool withProfile = true, bool withUser = true,
|
|
||||||
int? userId = null, string? username = null,
|
|
||||||
int? profileId = null, int? objId = null, bool? profileActive = null)
|
|
||||||
=> await Read(
|
|
||||||
isReadonly: isReadonly,
|
|
||||||
withProfile: withProfile, withUser: withUser,
|
|
||||||
userId: userId, username: username,
|
|
||||||
profileId: profileId, objId: objId)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories;
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, int, WFDBContext>, IProfileObjStateRepository, ICRUDRepository<ProfileObjState, int>
|
public class ProfileObjStateRepository : CRUDRepository<ProfileObjState, long, WFDBContext>, IProfileObjStateRepository, ICRUDRepository<ProfileObjState, long>
|
||||||
{
|
{
|
||||||
public ProfileObjStateRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileObjStates)
|
public ProfileObjStateRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileObjStates)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user