fixes, improvements

This commit is contained in:
Loretta 2024-06-25 19:04:42 +02:00
parent e32e6d2759
commit 79f941f4d6
2 changed files with 4 additions and 3 deletions

View File

@ -63,7 +63,7 @@ public static class AcCompanyDbSetExtensions
return ctx.Companies.Update(company).State == EntityState.Modified;
}
public static bool RemoveCompany<TCompany, TProfile, TAddress, TUserToCompany>(this IAcCompanyDbSetBase<TCompany, TProfile, TAddress, TUserToCompany> ctx, TCompany company)
private static bool RemoveCompany<TCompany, TProfile, TAddress, TUserToCompany>(this IAcCompanyDbSetBase<TCompany, TProfile, TAddress, TUserToCompany> ctx, TCompany company)
where TCompany : class, IAcCompany<TProfile, TAddress>
where TProfile : class, IAcProfile<TAddress>
where TAddress : class, IAcAddress

View File

@ -1,4 +1,5 @@
using AyCode.Core.Server.Loggers;
using AyCode.Database.DbSets.Addresses;
using AyCode.Database.DbSets.Profiles;
using AyCode.Entities;
using AyCode.Interfaces.Addresses;
@ -22,11 +23,11 @@ public static class AcProfileDbSetExtensions
public static bool UpdateProfile<TProfile>(this IAcProfileDbSetBase<TProfile> ctx, TProfile profile) where TProfile : class, IAcProfileDtoBase
=> ctx.Profiles.Update(profile).State == EntityState.Modified;
public static bool RemoveProfile<TProfile, TAddress>(this IAcProfileDbSetBase<TProfile, TAddress> ctx, TProfile profile)
private static bool RemoveProfile<TProfile, TAddress>(this IAcProfileDbSetBase<TProfile, TAddress> ctx, TProfile profile)
where TProfile : class, IAcProfile<TAddress>
where TAddress : class, IAcAddressDtoBase
{
var address = ctx.Addresses.FirstOrDefault(x => x.Id == profile.AddressId);
var address = ctx.GetAddressById(profile.AddressId);
if (address != null) ctx.Addresses.Remove(address);
return ctx.Profiles.Remove(profile).State == EntityState.Deleted;