Refactor GetOrCreateCommand and add AutoMapper profile
Refactored the `GetOrCreateCommand` to simplify the creation of `Endpoint` entities by delegating the creation logic to `repo.CreateAsync`. Added a new `MappingProfile` class using AutoMapper to define mappings between command objects (`CreateEndpointCommand` and `GetOrCreateCommand`) and the `Endpoint` entity, improving code maintainability and reducing boilerplate. Included necessary `using` directives in `MappingProfile.cs` to support the new mapping functionality.
This commit is contained in:
18
src/ReC.Application/Endpoints/MappingProfile.cs
Normal file
18
src/ReC.Application/Endpoints/MappingProfile.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using AutoMapper;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ReC.Application.Endpoints;
|
||||
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<CreateEndpointCommand, Endpoint>();
|
||||
CreateMap<GetOrCreateCommand, Endpoint>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user