diff --git a/DbFirst.Application/Catalogs/CatalogProfile.cs b/DbFirst.Application/Catalogs/CatalogProfile.cs index d30bd02..ca4bb3a 100644 --- a/DbFirst.Application/Catalogs/CatalogProfile.cs +++ b/DbFirst.Application/Catalogs/CatalogProfile.cs @@ -7,7 +7,7 @@ public class CatalogProfile : Profile { public CatalogProfile() { - CreateMap().ReverseMap(); + CreateMap(); CreateMap(); } } diff --git a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs index 449b446..0227349 100644 --- a/DbFirst.Infrastructure/Repositories/CatalogRepository.cs +++ b/DbFirst.Infrastructure/Repositories/CatalogRepository.cs @@ -34,18 +34,12 @@ public class CatalogRepository : ICatalogRepository public async Task UpdateAsync(int id, VwmyCatalog catalog, CancellationToken cancellationToken = default) { - var exists = await _db.VwmyCatalogs.AsNoTracking().AnyAsync(x => x.Guid == id, cancellationToken); - if (!exists) - { - return null; - } - catalog.Guid = id; var guidParam = new SqlParameter("@GUID", SqlDbType.Int) { - Direction = ParameterDirection.InputOutput, - Value = catalog.Guid == 0 ? DBNull.Value : catalog.Guid + Direction = ParameterDirection.Input, + Value = id }; var catTitleParam = new SqlParameter("@CAT_TITLE", catalog.CatTitle); @@ -53,17 +47,11 @@ public class CatalogRepository : ICatalogRepository var changedWhoParam = new SqlParameter("@CHANGED_WHO", (object?)catalog.ChangedWho ?? DBNull.Value); await _db.Database.ExecuteSqlRawAsync( - "EXEC dbo.PRTBMY_CATALOG_UPDATE @CAT_TITLE, @CAT_STRING, @CHANGED_WHO, @GUID OUTPUT", + "EXEC dbo.PRTBMY_CATALOG_UPDATE @CAT_TITLE, @CAT_STRING, @CHANGED_WHO, @GUID", parameters: new[] { catTitleParam, catStringParam, changedWhoParam, guidParam }, cancellationToken: cancellationToken); - if (guidParam.Value == DBNull.Value) - { - return null; - } - - var guid = (int)guidParam.Value; - return await _db.VwmyCatalogs.AsNoTracking().FirstOrDefaultAsync(x => x.Guid == guid, cancellationToken); + return await _db.VwmyCatalogs.AsNoTracking().FirstOrDefaultAsync(x => x.Guid == id, cancellationToken); } public async Task DeleteAsync(int id, CancellationToken cancellationToken = default)