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 WorkFlow.API.Attributes;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.Config;
|
||||
using WorkFlow.Application.Dto.Config;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.API.Controllers;
|
||||
|
||||
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlow.API.Attributes;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||
using WorkFlow.Application.Dto.ProfileControlsTF;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.API.Controllers;
|
||||
@ -13,53 +13,20 @@ namespace WorkFlow.API.Controllers;
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[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)
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||
|
||||
[NonAction]
|
||||
[HttpPut]
|
||||
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]
|
||||
[HttpPost]
|
||||
public override async Task<IActionResult> Create([FromBody] ProfileControlsTFCreateDto createDto)
|
||||
@ -68,7 +35,7 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
||||
{
|
||||
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.");
|
||||
}
|
||||
|
||||
@ -79,20 +46,20 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[HttpDelete]
|
||||
public override async Task<IActionResult> Delete([FromRoute] int id)
|
||||
public override async Task<IActionResult> Delete([FromRoute] long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
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.");
|
||||
}
|
||||
|
||||
@ -106,7 +73,7 @@ public class ProfileControlsTFController : CRUDControllerBase<IProfileControlsTF
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlow.API.Attributes;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.ProfileObjState;
|
||||
using WorkFlow.Application.Dto.ProfileObjState;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.API.Controllers
|
||||
@ -13,7 +13,7 @@ namespace WorkFlow.API.Controllers
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[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;
|
||||
|
||||
@ -84,7 +84,7 @@ namespace WorkFlow.API.Controllers
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public override async Task<IActionResult> Delete([FromRoute] int id)
|
||||
public override async Task<IActionResult> Delete([FromRoute] long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlow.API.Attributes;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.State;
|
||||
using WorkFlow.Application.Dto.State;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.API.Controllers;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Abstractions.Application;
|
||||
using WorkFlow.Application.DTO.Config;
|
||||
using WorkFlow.Application.Dto.Config;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.Application.Contracts
|
||||
|
||||
@ -1,15 +1,9 @@
|
||||
using DigitalData.Core.Abstractions.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||
using WorkFlow.Application.Dto.ProfileControlsTF;
|
||||
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.DTO;
|
||||
using WorkFlow.Application.DTO.ProfileObjState;
|
||||
using WorkFlow.Application.Dto.ProfileObjState;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
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(
|
||||
bool withProfile = true, bool withUser = true, bool withState = true,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Abstractions.Application;
|
||||
using WorkFlow.Application.DTO.State;
|
||||
using WorkFlow.Application.Dto.State;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
namespace WorkFlow.Application.Contracts
|
||||
|
||||
@ -3,11 +3,6 @@ using WorkFlow.Domain.Entities;
|
||||
|
||||
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;
|
||||
|
||||
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, int>
|
||||
public interface IProfileObjStateRepository : ICRUDRepository<ProfileObjState, long>
|
||||
{
|
||||
Task<IEnumerable<ProfileObjState>> ReadAsync(
|
||||
bool isReadonly = true,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WorkFlow.Application.DTO
|
||||
namespace WorkFlow.Application.Dto
|
||||
{
|
||||
public record BaseCreateDto
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstractions;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WorkFlow.Application.DTO
|
||||
namespace WorkFlow.Application.Dto
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
namespace WorkFlow.Application.DTO.Config
|
||||
namespace WorkFlow.Application.Dto.Config
|
||||
{
|
||||
public record ConfigDto(int Id,
|
||||
string Title,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
namespace WorkFlow.Application.DTO.Config
|
||||
namespace WorkFlow.Application.Dto.Config
|
||||
{
|
||||
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(
|
||||
int ProfileId,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
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,
|
||||
int ProfileId,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using DigitalData.Core.Abstractions;
|
||||
|
||||
namespace WorkFlow.Application.DTO.ProfileControlsTF
|
||||
namespace WorkFlow.Application.Dto.ProfileControlsTF
|
||||
{
|
||||
/// <summary>
|
||||
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
||||
/// </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(
|
||||
int ProfileId,
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
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,
|
||||
int ProfileId,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using DigitalData.Core.Abstractions;
|
||||
|
||||
namespace WorkFlow.Application.DTO.ProfileObjState
|
||||
namespace WorkFlow.Application.Dto.ProfileObjState
|
||||
{
|
||||
/// <summary>
|
||||
/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates.
|
||||
/// </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;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using DigitalData.Core.Abstractions;
|
||||
|
||||
namespace WorkFlow.Application.DTO.State
|
||||
namespace WorkFlow.Application.Dto.State
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.DTO.Config;
|
||||
using WorkFlow.Application.DTO.Profile;
|
||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||
using WorkFlow.Application.DTO.ProfileObjState;
|
||||
using WorkFlow.Application.DTO.State;
|
||||
using WorkFlow.Application.Buttons;
|
||||
using WorkFlow.Application.Dto;
|
||||
using WorkFlow.Application.Dto.Config;
|
||||
using WorkFlow.Application.Dto.ProfileControlsTF;
|
||||
using WorkFlow.Application.Dto.ProfileObjState;
|
||||
using WorkFlow.Application.Dto.State;
|
||||
using WorkFlow.Application.Objects;
|
||||
using WorkFlow.Application.Profiles;
|
||||
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>();
|
||||
CreateMap<Domain.Entities.Profile, ProfileDto>();
|
||||
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
|
||||
CreateMap<ProfileObjState, ProfileObjStateDto>();
|
||||
CreateMap<State, StateDto>();
|
||||
CreateMap<Button, ButtonDto>();
|
||||
CreateMap<ProfileObject, ObjectDto>()
|
||||
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src =>
|
||||
new[] { src.Headline1, src.Headline2 }))
|
||||
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src =>
|
||||
new[] { src.Subline1, src.Subline2 }));
|
||||
// Mapping entity to DTO
|
||||
CreateMap<Config, ConfigDto>();
|
||||
CreateMap<Profile, ProfileDto>();
|
||||
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
|
||||
CreateMap<ProfileObjState, ProfileObjStateDto>();
|
||||
CreateMap<State, StateDto>();
|
||||
CreateMap<Button, ButtonDto>();
|
||||
CreateMap<ProfileObject, ObjectDto>()
|
||||
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src =>
|
||||
new[] { src.Headline1, src.Headline2 }))
|
||||
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src =>
|
||||
new[] { src.Subline1, src.Subline2 }));
|
||||
|
||||
|
||||
// Mapping create-DTO to entity
|
||||
CreateMap<ConfigCreateDto, Config>();
|
||||
CreateMap<ProfileCreateDto, Domain.Entities.Profile>();
|
||||
CreateMap<ProfileControlsTFCreateDto, ProfileControlsTF>();
|
||||
CreateMap<ProfileObjStateCreateDto, ProfileObjState>();
|
||||
CreateMap<StateCreateDto, State>();
|
||||
// Mapping create-DTO to entity
|
||||
CreateMap<ConfigCreateDto, Config>();
|
||||
CreateMap<ProfileControlsTFCreateDto, ProfileControlsTF>();
|
||||
CreateMap<ProfileObjStateCreateDto, ProfileObjState>();
|
||||
CreateMap<StateCreateDto, State>();
|
||||
|
||||
// Mapping update-DTO to entity
|
||||
CreateMap<ConfigUpdateDto, Config>();
|
||||
CreateMap<ProfileUpdateDto, Domain.Entities.Profile>();
|
||||
CreateMap<ProfileControlsTFUpdateDto, ProfileControlsTF>();
|
||||
CreateMap<ProfileObjStateUpdateDto, ProfileObjState>();
|
||||
CreateMap<StateUpdateDto, State>();
|
||||
}
|
||||
// Mapping update-DTO to entity
|
||||
CreateMap<ConfigUpdateDto, Config>();
|
||||
CreateMap<ProfileControlsTFUpdateDto, ProfileControlsTF>();
|
||||
CreateMap<ProfileObjStateUpdateDto, ProfileObjState>();
|
||||
CreateMap<StateUpdateDto, State>();
|
||||
}
|
||||
}
|
||||
@ -2,42 +2,21 @@
|
||||
using MediatR;
|
||||
using WorkFlow.Application.Buttons;
|
||||
using WorkFlow.Application.Contracts.Repositories;
|
||||
using WorkFlow.Application.Objects;
|
||||
using WorkFlow.Application.Dto;
|
||||
|
||||
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>
|
||||
/// Represents a request to read a user profile by their user ID.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// 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"/>.
|
||||
/// </summary>
|
||||
public class ReadProfileHandler : IRequestHandler<ReadProfileRequest, ProfileDto?>
|
||||
public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto?>
|
||||
{
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
|
||||
@ -61,13 +40,13 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileRequest, ProfileDto
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the user ID.</param>
|
||||
/// <param name="cancel">A cancellation token for the operation.</param>
|
||||
/// <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);
|
||||
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)
|
||||
=> 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.Application;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.Config;
|
||||
using WorkFlow.Application.Dto.Config;
|
||||
using WorkFlow.Domain.Entities;
|
||||
using WorkFlow.Application.Contracts.Repositories;
|
||||
|
||||
|
||||
@ -3,33 +3,22 @@ using DigitalData.Core.Abstractions.Application;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.ProfileControlsTF;
|
||||
using WorkFlow.Application.Dto.ProfileControlsTF;
|
||||
using WorkFlow.Domain.Entities;
|
||||
using WorkFlow.Application.Contracts.Repositories;
|
||||
|
||||
namespace WorkFlow.Application.Services
|
||||
{
|
||||
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>,
|
||||
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, int>
|
||||
public class ProfileControlsTFService : CRUDService<IProfileControlsTFRepository, ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>,
|
||||
IProfileControlsTFService, ICRUDService<ProfileControlsTFCreateDto, ProfileControlsTFDto, ProfileControlsTF, long>
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,14 +3,14 @@ using DigitalData.Core.Abstractions.Application;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.ProfileObjState;
|
||||
using WorkFlow.Application.Dto.ProfileObjState;
|
||||
using WorkFlow.Domain.Entities;
|
||||
using WorkFlow.Application.Contracts.Repositories;
|
||||
|
||||
namespace WorkFlow.Application.Services;
|
||||
|
||||
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>,
|
||||
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, int>
|
||||
public class ProfileObjStateService : CRUDService<IProfileObjStateRepository, ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>,
|
||||
IProfileObjStateService, ICRUDService<ProfileObjStateCreateDto, ProfileObjStateDto, ProfileObjState, long>
|
||||
{
|
||||
public ProfileObjStateService(IProfileObjStateRepository repository, IMapper mapper) : base(repository, mapper)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using DigitalData.Core.Abstractions.Application;
|
||||
using DigitalData.Core.Application;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Application.DTO.State;
|
||||
using WorkFlow.Application.Dto.State;
|
||||
using WorkFlow.Domain.Entities;
|
||||
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;
|
||||
|
||||
namespace WorkFlow.Domain.Entities;
|
||||
|
||||
[Table("TBMWF_PROF_CONTROLS_TF", Schema = "dbo")]
|
||||
public class ProfileControlsTF
|
||||
public class ProfileControlsTF : IUnique<long>
|
||||
{
|
||||
[Key]
|
||||
[Column("GUID", TypeName = "bigint")]
|
||||
|
||||
@ -6,48 +6,9 @@ using WorkFlow.Domain.Entities;
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user