@ -6,338 +6,326 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace Gremlin_BlazorServer.Services ;
namespace Gremlin_BlazorServer.Services ;
public class GenericController {
public class GenericController {
public IList < TResult > ? GetAll < TResult > ( ) where TResult : class , IMetadata {
private static readonly GremlinDb gremlinDb = new ( ) ;
try {
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . ToList ( ) ;
}
catch ( Exception exception ) {
Console . WriteLine ( exception . InnerException ) ;
return null ;
}
}
public IList < TResult > ? GetAll < TResult > ( string include ) where TResult : class , IMetadata {
public IList < TResult > ? GetAll < TResult > ( ) where TResult : class , IMetadata {
try {
try {
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . Include ( include ) . ToList ( ) ;
return gremlinDb . Set < TResult > ( ) . ToList ( ) ;
}
}
catch ( Exception exception ) {
catch ( Exception exception ) {
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public IList < TResult > ? GetAll < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
public IList < TResult > ? GetAll < TResult > ( string include ) where TResult : class , IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
return gremlinDb . Set < TResult > ( ) . Include ( include ) . ToList ( ) ;
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ;
}
}
catch ( Exception exception ) {
catch ( Exception exception ) {
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( ) where TResult : class , IMetadata {
public IList < TResult > ? GetAll < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
try {
ArgumentNullException . ThrowIfNull ( search ) ;
await using ( GremlinDb gremlinDb = new ( ) ) return await gremlinDb . Set < TResult > ( ) . ToListAsync ( ) ;
try {
}
return gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ;
catch ( DbUpdateConcurrencyException exception ) {
}
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
catch ( Exception exception ) {
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( string include ) where TResult : class , IMetadata {
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( ) where TResult : class , IMetadata {
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) return await gremlinDb . Set < TResult > ( ) . Include ( include ) . ToListAsync ( ) ;
return await gremlinDb . Set < TResult > ( ) . ToListAsync ( ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
catch ( DbUpdateConcurrencyException exception ) {
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( string include 1, string include2 ) where TResult : class , IMetadata {
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( string include ) where TResult : class , IMetadata {
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) return await gremlinDb . Set < TResult > ( ) . Include ( include 1) . Include ( include2 ) . ToListAsync ( ) ;
return await gremlinDb . Set < TResult > ( ) . Include ( include ) . ToListAsync ( ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
catch ( DbUpdateConcurrencyException exception ) {
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( string include1 , string include2 ) where TResult : class , IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
return await gremlinDb . Set < TResult > ( ) . Include ( include1 ) . Include ( include2 ) . ToListAsync ( ) ;
await using ( GremlinDb gremlinDb = new ( ) ) return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
catch ( DbUpdateConcurrencyException exception ) {
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( Predicate < TResult > search , string include ) where TResult : class , IMetadata {
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ) ;
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
catch ( DbUpdateConcurrencyException exception ) {
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return null ;
}
}
}
}
public IList < TResult > ? GetAll < TResult > ( Predicate < TResult > search , string include ) where TResult : class , IMetadata {
public async Task < IList < TResult > ? > GetAllAsync < TResult > ( Predicate < TResult > search , string include ) where TResult : class , IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . Include ( include ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ;
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include ) . AsEnumerable ( ) . Where ( t = > search ( t ) ) . ToList ( ) ) ;
}
}
catch ( Exception exception ) {
catch ( DbUpdateConcurrencyException exception ) {
Console . WriteLine ( exception . InnerException ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
return null ;
Console . WriteLine ( exception . InnerException ) ;
}
return null ;
}
}
}
public TResult ? Get < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
// public IList<TResult>? GetAll<TResult>(Predicate<TResult> search, string include) where TResult : class, IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
// ArgumentNullException.ThrowIfNull(search) ;
try {
// try {
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . FirstOrDefault ( t = > search ( t ) ) ;
// return gremlinDb.Set<TResult>().Include(include).AsEnumerable().Where(t => search(t)).ToList() ;
}
// }
catch ( Exception exception ) {
// catch (Exception exception) {
Console . WriteLine ( exception . InnerException ) ;
// Console.WriteLine(exception.InnerException) ;
return null ;
// return null ;
}
// }
}
// }
public async Task < TResult ? > GetAsync < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata {
// public TResult? Get<TResult>(Predicate<TResult> search) where TResult : class, IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
// ArgumentNullException.ThrowIfNull(search) ;
try {
// try {
await using ( GremlinDb gremlinDb = new ( ) ) return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . FirstOrDefault ( t = > search ( t ) ) ) ;
// using GremlinDb gremlinDb = new() ;
}
// return gremlinDb.Set<TResult>().AsEnumerable().FirstOrDefault(t => search(t));
catch ( DbUpdateConcurrencyException exception ) {
// }
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
// catch (Exception exception) {
Console . WriteLine ( exception . InnerException ) ;
// Console.WriteLine(exception.InnerException) ;
return null ;
// return null ;
}
// }
}
// }
public TResult ? Get < TResult > ( Predicate < TResult > search , string include ) where TResult : class , IMetadata {
public static async Task < TResult > GetAsync < TResult > ( Predicate < TResult > search ) where TResult : class , IMetadata , new ( ) {
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . First ( t = > search ( t ) ) ) ;
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . AsNoTracking ( ) . Include ( include ) . AsEnumerable ( ) . FirstOrDefault ( t = > search ( t ) ) ;
}
}
catch ( Exception e ) {
catch ( Exception exception ) {
Console . WriteLine ( e . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return new ( ) ;
return null ;
}
}
}
}
public async Task < TResult ? > GetAsync < TResult > ( Predicate < TResult > search , string include1 ) where TResult : class , IMetadata {
// public TResult? Get<TResult>(Predicate<TResult> search, string include) where TResult : class, IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
// ArgumentNullException.ThrowIfNull(search) ;
try {
// try {
await using ( GremlinDb gremlinDb = new ( )) return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include1 ) . AsEnumerable ( ) . FirstOrDefault ( t = > search ( t ) ) ) ;
// using GremlinDb gremlinDb = new();
}
// return gremlinDb.Set<TResult>().AsNoTracking().Include(include).AsEnumerable().FirstOrDefault(t => search(t));
catch ( DbUpdateConcurrencyException exception ) {
// }
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
// catch (Exception exception) {
Console . WriteLine ( exception . InnerException ) ;
// Console.WriteLine(exception.InnerException) ;
return null ;
// return null ;
}
// }
}
// }
public async Task < TResult ? > GetAsync < TResult > ( Predicate < TResult > search , string include1 , string include2 ) where TResult : class , IMetadata {
public async Task < TResult > GetAsync < TResult > ( Predicate < TResult > search , string include1 ) where TResult : class , IMetadata , new ( ) {
ArgumentNullException . ThrowIfNull ( search ) ;
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include1 ) . Include( include2 ) . AsEnumerable( ) . Firs tOrDefaul t( t = > search ( t ) ) ) ;
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include1 ) . AsEnumerable( ) . Firs t( t = > search ( t ) ) ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
catch ( DbUpdateConcurrencyException exception ) {
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
Console . WriteLine ( exception . InnerException ) ;
Console . WriteLine ( exception . InnerException ) ;
return null ;
return new ( ) ;
}
}
}
}
public TResult ? GetLast < TResult > ( ) where TResult : class , IMetadata {
public async Task < TResult > GetAsync < TResult > ( Predicate < TResult > search , string include1 , string include2 ) where TResult : class , IMetadata , new ( ) {
try {
ArgumentNullException . ThrowIfNull ( search ) ;
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Last ( ) ;
try {
}
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . Include ( include1 ) . Include ( include2 ) . AsEnumerable ( ) . First ( t = > search ( t ) ) ) ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
catch ( DbUpdateConcurrencyException exception ) {
return null ;
await HandleDbUpdateConcurrencyException < TResult > ( exception ) ;
}
Console . WriteLine ( exception . InnerException ) ;
}
return new ( ) ;
}
}
public int Insert < T > ( T entity ) where T : class , IMetadata {
public static async Task < TResult > GetLastAsync < TResult > ( ) where TResult : class , IMetadata , new ( ) {
try {
try {
using ( GremlinDb gremlinDb = new ( ) ) {
return await Task . Run ( ( ) = > gremlinDb . Set < TResult > ( ) . AsEnumerable ( ) . Last ( ) ) ;
gremlinDb . Set < T > ( ) . Add ( entity ) ;
}
return gremlinDb . SaveChanges ( ) ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
}
return new ( ) ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
}
}
public int Insert < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
// public int Insert<T>(T entity) where T : class, IMetadata {
try {
// try {
using ( GremlinDb gremlinDb = new ( ) ) {
// using GremlinDb gremlinDb = new();
gremlinDb . Set < T > ( ) . AddRange ( entities ) ;
// gremlinDb.Set<T>().Add(entity);
return gremlinDb . SaveChanges ( ) ;
// return gremlinDb.SaveChanges();
}
// }
}
// catch (Exception exception) {
catch ( Exception exception ) {
// Console.WriteLine(exception.InnerException);
Console . WriteLine ( exception . InnerException ) ;
// return 0;
return 0 ;
// }
}
// }
}
public async Task < int > InsertAsync < T > ( T entity ) where T : class , IMetadata {
// public int Insert<T>(IEnumerable<T> entities) where T : class, IMetadata {
try {
// try {
await using ( GremlinDb gremlinDb = new ( ) ) {
// using GremlinDb gremlinDb = new();
gremlinDb . Set < T > ( ) . Add ( entity ) ;
// gremlinDb.Set<T>().AddRange(entities);
return await gremlinDb . SaveChangesAsync ( ) ;
// return gremlinDb.SaveChanges();
}
// }
}
// catch (Exception exception) {
catch ( DbUpdateConcurrencyException exception ) {
// Console.WriteLine(exception.InnerException);
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
// return 0;
Console . WriteLine ( exception . InnerException ) ;
// }
return 0 ;
// }
}
}
public async Task < int > InsertAsync < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
public async Task < int > InsertAsync < T > ( T entity ) where T : class , IMetadata {
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) {
gremlinDb . Set < T > ( ) . Add ( entity ) ;
gremlinDb . Set < T > ( ) . AddRange ( entities ) ;
return await gremlinDb . SaveChangesAsync ( ) ;
return await gremlinDb . SaveChangesAsync ( ) ;
}
}
catch ( DbUpdateConcurrencyException exception ) {
}
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
catch ( DbUpdateConcurrencyException exception ) {
Console . WriteLine ( exception . InnerException ) ;
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
return 0 ;
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
}
}
}
public static bool IsExisting < T > ( Predicate < T > search ) where T : class , IMetadata {
public async Task < int > InsertAsync < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
ArgumentNullException . ThrowIfNull ( search ) ;
try {
try {
gremlinDb . Set < T > ( ) . AddRange ( entities ) ;
using ( GremlinDb gremlinDb = new ( ) ) return gremlinDb . Set < T > ( ) . AsEnumerable ( ) . Any ( t = > search ( t ) ) ;
return await gremlinDb . SaveChangesAsync ( ) ;
}
}
catch ( Exception exception ) {
catch ( DbUpdateConcurrencyException exception ) {
Console . WriteLine ( exception . InnerException ) ;
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
return false ;
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
}
}
}
public int Update < T > ( T entity ) where T : class , IMetadata {
public static async Task < bool > IsExistingAsync < T > ( Predicate < T > search ) where T : class , IMetadata {
try {
try {
using ( GremlinDb gremlinDb = new ( ) ) {
return await Task . Run ( ( ) = > gremlinDb . Set < T > ( ) . AsEnumerable ( ) . Any ( t = > search ( t ) ) ) ;
gremlinDb . Set < T > ( ) . Update ( entity ) ;
}
return gremlinDb . SaveChanges ( ) ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
}
return false ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
}
}
public async Task < int > UpdateAsync < T > ( T entity ) where T : class , IMetadata {
// public int Update<T>(T entity) where T : class, IMetadata {
await using ( GremlinDb gremlinDb = new ( ) ) {
// try {
try {
// using GremlinDb gremlinDb = new();
gremlinDb . Set < T > ( ) . Update ( entity ) ;
// gremlinDb.Set<T>().Update(entity);
return await gremlinDb . SaveChangesAsync ( false ) ;
// return gremlinDb.SaveChanges();
}
// }
catch ( DbUpdateConcurrencyException exception ) {
// catch (Exception exception) {
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
// Console.WriteLine(exception.InnerException);
Console . WriteLine ( exception . InnerException ) ;
// return 0;
return 0 ;
// }
}
// }
}
}
private async Task HandleDbUpdateConcurrencyException < T > ( DbUpdateConcurrencyException exception ) where T : class , IMetadata {
public async Task < int > UpdateAsync < T > ( T entity ) where T : class , IMetadata {
// Loop through the entities that caused the concurrency conflict
try {
foreach ( EntityEntry ? entry in exception . Entries ) {
gremlinDb . Set < T > ( ) . Update ( entity ) ;
if ( entry . Entity is T ) {
return await gremlinDb . SaveChangesAsync ( false ) ;
T ? clientValues = ( T ) entry . Entity ;
}
PropertyValues ? databaseEntry = await entry . GetDatabaseValuesAsync ( ) ;
catch ( DbUpdateConcurrencyException exception ) {
if ( databaseEntry is null )
await HandleDbUpdateConcurrencyException < T > ( exception ) ;
// The record has been deleted from the database
Console . WriteLine ( exception . InnerException ) ;
// Notify the user or handle the error in some other way
return 0 ;
throw new ( "The record has been deleted from the database." ) ;
}
T ? databaseValues = ( T ) databaseEntry . ToObject ( ) ;
}
// Compare the database values with the client values
if ( databaseValues . DataVersionNumber ! = clientValues . DataVersionNumber )
// The name has been changed by another user
// Notify the user or handle the error in some other way
throw new ( "The record has been modified by another user." ) ;
// The conflict is caused by a property other than the name
// Notify the user or handle the error in some other way
throw new ( "A concurrency conflict occurred." ) ;
}
// Handle concurrency conflicts for other entity types, if necessary
private static async Task HandleDbUpdateConcurrencyException < T > ( DbUpdateConcurrencyException exception ) where T : class , IMetadata {
throw new NotSupportedException ( $"Concurrency conflicts for entities of type {entry.Entity.GetType().Name} are not supported." ) ;
// Loop through the entities that caused the concurrency conflict
}
foreach ( EntityEntry ? entry in exception . Entries ) {
}
if ( entry . Entity is not T clientValues ) throw new NotSupportedException ( $"Concurrency conflicts for entities of type {entry.Entity.GetType().Name} are not supported." ) ;
PropertyValues ? databaseEntry = await entry . GetDatabaseValuesAsync ( ) ;
if ( databaseEntry is null )
// The record has been deleted from the database
// Notify the user or handle the error in some other way
throw new ( "The record has been deleted from the database." ) ;
T databaseValues = ( T ) databaseEntry . ToObject ( ) ;
// Compare the database values with the client values
if ( databaseValues . DataVersionNumber ! = clientValues . DataVersionNumber )
// The name has been changed by another user
// Notify the user or handle the error in some other way
throw new ( "The record has been modified by another user." ) ;
// The conflict is caused by a property other than the name
// Notify the user or handle the error in some other way
throw new ( "A concurrency conflict occurred." ) ;
public int Update < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
// Handle concurrency conflicts for other entity types, if necessary
try {
}
using ( GremlinDb gremlinDb = new ( ) ) {
}
gremlinDb . Set < T > ( ) . UpdateRange ( entities ) ;
return gremlinDb . SaveChanges ( ) ;
}
}
catch ( Exception exception ) {
Console . WriteLine ( exception . InnerException ) ;
return 0 ;
}
}
public async Task < int > UpdateAsync < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
// public int Update<T>(IEnumerable<T> entities) where T : class, IMetadata {
try {
// try {
await using ( GremlinDb gremlinDb = new ( ) ) {
// using GremlinDb gremlinDb = new();
gremlinDb . Set < T > ( ) . UpdateRange ( entities ) ;
// gremlinDb.Set<T>().UpdateRange(entities);
return await gremlinDb . SaveChangesAsync ( ) ;
// return gremlinDb.SaveChanges();
}
// }
}
// catch (Exception exception) {
catch ( Exception exception ) {
// Console.WriteLine(exception.InnerException);
Console . WriteLine ( exception . InnerException ) ;
// return 0;
return 0 ;
// }
}
// }
}
public async Task < int > RemoveAsync < T > ( T entity ) where T : class , IMetadata {
public static async Task < int > UpdateAsync < T > ( IEnumerable < T > entities ) where T : class , IMetadata {
try {
try {
await using ( GremlinDb gremlinDb = new ( ) ) {
await Task . Run ( ( ) = > gremlinDb . Set < T > ( ) . UpdateRange ( entities ) ) ;
gremlinDb . Set < T > ( ) . Remove ( entity ) ;
return await gremlinDb . SaveChangesAsync ( ) ;
return await gremlinDb . SaveChangesAsync ( ) ;
}
}
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
catch ( Exception exception ) {
return 0 ;
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
}
}
}
public static async Task < int > RemoveAsync < T > ( T entity ) where T : class , IMetadata {
try {
public async Task < Account > ResolveAccountById ( uint accountId ) {
await Task . Run ( ( ) = > gremlinDb . Set < T > ( ) . Remove ( entity ) ) ;
try {
return await gremlinDb . SaveChangesAsync ( ) ;
await using ( GremlinDb gremlinDb = new ( ) ) {
}
return gremlinDb . Accounts . First ( a = > a . AccountId . Equals ( accountId ) ) ;
catch ( Exception exception ) {
}
Console . WriteLine ( exception . InnerException ) ;
}
return 0 ;
catch {
}
return new Account ( ) ;
}
}
}
// public async Task<Account?> ResolveAccountById(uint accountId){
// try {
//
// if (gremlinDb.Accounts != null)
// return gremlinDb.Accounts.First(a => a.AccountId.Equals(accountId));
// else {
// return null;
// }
// }
// catch (Exception exception){
// Console.WriteLine(exception.InnerException);
// return null;
// }
// }
}
}