Refactor to use VwmyCatalog as primary catalog entity
Replaced all usage of the Catalog entity with VwmyCatalog across application, domain, and infrastructure layers. Updated AutoMapper profiles, repository interfaces, and service logic to use VwmyCatalog. Removed the obsolete Catalog entity and related mapping profiles. Moved VwmyCatalog to the Domain.Entities namespace and cleaned up project structure. This change simplifies the domain model and eliminates redundant entity definitions.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using AutoMapper;
|
||||
using DbFirst.Domain.DomainEntities;
|
||||
using DbFirst.Domain.Repositories;
|
||||
using DbFirst.Domain.Entities;
|
||||
|
||||
namespace DbFirst.Application.Catalogs;
|
||||
|
||||
@@ -17,25 +17,25 @@ public class CatalogService : ICatalogService
|
||||
|
||||
public async Task<List<CatalogReadDto>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var domainItems = await _repository.GetAllAsync(cancellationToken);
|
||||
return _mapper.Map<List<CatalogReadDto>>(domainItems);
|
||||
var items = await _repository.GetAllAsync(cancellationToken);
|
||||
return _mapper.Map<List<CatalogReadDto>>(items);
|
||||
}
|
||||
|
||||
public async Task<CatalogReadDto?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var domainItem = await _repository.GetByIdAsync(id, cancellationToken);
|
||||
return domainItem == null ? null : _mapper.Map<CatalogReadDto>(domainItem);
|
||||
var item = await _repository.GetByIdAsync(id, cancellationToken);
|
||||
return item == null ? null : _mapper.Map<CatalogReadDto>(item);
|
||||
}
|
||||
|
||||
public async Task<CatalogReadDto> CreateAsync(CatalogWriteDto dto, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var domainItem = _mapper.Map<Catalog>(dto);
|
||||
domainItem.AddedWho = "system";
|
||||
domainItem.AddedWhen = DateTime.UtcNow;
|
||||
domainItem.ChangedWho = "system";
|
||||
domainItem.ChangedWhen = DateTime.UtcNow;
|
||||
var entity = _mapper.Map<VwmyCatalog>(dto);
|
||||
entity.AddedWho = "system";
|
||||
entity.AddedWhen = DateTime.UtcNow;
|
||||
entity.ChangedWho = "system";
|
||||
entity.ChangedWhen = DateTime.UtcNow;
|
||||
|
||||
var created = await _repository.AddAsync(domainItem, cancellationToken);
|
||||
var created = await _repository.AddAsync(entity, cancellationToken);
|
||||
return _mapper.Map<CatalogReadDto>(created);
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ public class CatalogService : ICatalogService
|
||||
return false;
|
||||
}
|
||||
|
||||
var domainItem = _mapper.Map<Catalog>(dto);
|
||||
domainItem.Guid = id;
|
||||
domainItem.AddedWho = existing.AddedWho;
|
||||
domainItem.AddedWhen = existing.AddedWhen;
|
||||
domainItem.ChangedWho = "system";
|
||||
domainItem.ChangedWhen = DateTime.UtcNow;
|
||||
return await _repository.UpdateAsync(id, domainItem, cancellationToken);
|
||||
var entity = _mapper.Map<VwmyCatalog>(dto);
|
||||
entity.Guid = id;
|
||||
entity.AddedWho = existing.AddedWho;
|
||||
entity.AddedWhen = existing.AddedWhen;
|
||||
entity.ChangedWho = "system";
|
||||
entity.ChangedWhen = DateTime.UtcNow;
|
||||
return await _repository.UpdateAsync(id, entity, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<CatalogReadDto?> UpdateWithStoredProcedureAsync(int id, CatalogWriteDto dto, CancellationToken cancellationToken = default)
|
||||
@@ -64,14 +64,14 @@ public class CatalogService : ICatalogService
|
||||
return null;
|
||||
}
|
||||
|
||||
var domainItem = _mapper.Map<Catalog>(dto);
|
||||
domainItem.Guid = id;
|
||||
domainItem.AddedWho = existing.AddedWho;
|
||||
domainItem.AddedWhen = existing.AddedWhen;
|
||||
domainItem.ChangedWho = "system";
|
||||
domainItem.ChangedWhen = DateTime.UtcNow;
|
||||
var entity = _mapper.Map<VwmyCatalog>(dto);
|
||||
entity.Guid = id;
|
||||
entity.AddedWho = existing.AddedWho;
|
||||
entity.AddedWhen = existing.AddedWhen;
|
||||
entity.ChangedWho = "system";
|
||||
entity.ChangedWhen = DateTime.UtcNow;
|
||||
|
||||
var updated = await _repository.UpdateWithStoredProcedureAsync(domainItem, cancellationToken);
|
||||
var updated = await _repository.UpdateWithStoredProcedureAsync(entity, cancellationToken);
|
||||
return updated == null ? null : _mapper.Map<CatalogReadDto>(updated);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user