public async Task <IActionResult> GetEmail() { var user = await _queryBuilder .ForGeneric <User>() .Where(UserSpecifications.WithId(_contextService.GetUserId())) .FirstOrDefaultAsync(); return(Ok(user.Email)); }
public override Task <int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)) { ChangeTracker.DetectChanges(); foreach (var entry in ChangeTracker.Entries()) { if (entry.Entity is IAuditableEntity) { if (entry.State == EntityState.Modified) { entry.Property("modifiedDate").CurrentValue = DateTime.UtcNow; entry.Property("modifiedBy").CurrentValue = userContextService.GetUserId(); } if (entry.State == EntityState.Added) { entry.Property("createdDate").CurrentValue = DateTime.UtcNow; entry.Property("createdBy").CurrentValue = userContextService.GetUserId(); } } if (entry.Entity is ITenancyEntity && entry.State == EntityState.Added) { entry.Property("TenantId").CurrentValue = tenantContextService.GetTenantId(); } if (entry.Entity is ISoftDeletableEntity) { if (entry.State == EntityState.Deleted) { entry.State = EntityState.Modified; entry.Property("isDeleted").CurrentValue = true; } if (entry.State == EntityState.Added) { entry.Property("isDeleted").CurrentValue = false; } } } return(base.SaveChangesAsync(cancellationToken)); }