public async Task ValidateUniqueId <T>(IBaseDao <T> dao, long id) where T : BaseEntity <T> { if (await dao.ExistByIdAsync(id)) { var duplicateEntryException = new DuplicateEntryException(id, "Entity already exists!"); Logger.Error(duplicateEntryException, "{type} with {id} already exists!", typeof(T), id); throw duplicateEntryException; } }
public async Task ValidateId <T>(IBaseDao <T> dao, long id) where T : BaseEntity <T> { if (!await dao.ExistByIdAsync(id)) { var invalidEntityIdException = new InvalidEntityIdException(id, "Entity with this id does not exist!"); Logger.Error(invalidEntityIdException, "{type} with {id} does not exist!", typeof(T), id); throw invalidEntityIdException; } }