-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from pkuehnel/develop
Develop
- Loading branch information
Showing
79 changed files
with
1,932 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
TeslaSolarCharger.Model/Contracts/ITeslaSolarChargerContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.ChangeTracking; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using TeslaSolarCharger.Model.Entities.TeslaSolarCharger; | ||
|
||
namespace TeslaSolarCharger.Model.Contracts; | ||
|
||
public interface ITeslaSolarChargerContext | ||
{ | ||
DbSet<ChargePrice> ChargePrices { get; set; } | ||
DbSet<HandledCharge> HandledCharges { get; set; } | ||
DbSet<PowerDistribution> PowerDistributions { get; set; } | ||
ChangeTracker ChangeTracker { get; } | ||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()); | ||
DatabaseFacade Database { get; } | ||
void RejectChanges(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Address.cs → ...arger.Model/Entities/TeslaMate/Address.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Car.cs → ...arCharger.Model/Entities/TeslaMate/Car.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...SolarCharger.Model/Entities/CarSetting.cs → ...er.Model/Entities/TeslaMate/CarSetting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Charge.cs → ...harger.Model/Entities/TeslaMate/Charge.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Charger.Model/Entities/ChargingProcess.cs → ...del/Entities/TeslaMate/ChargingProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Drive.cs → ...Charger.Model/Entities/TeslaMate/Drive.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Geofence.cs → ...rger.Model/Entities/TeslaMate/Geofence.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Position.cs → ...rger.Model/Entities/TeslaMate/Position.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Charger.Model/Entities/SchemaMigration.cs → ...del/Entities/TeslaMate/SchemaMigration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Setting.cs → ...arger.Model/Entities/TeslaMate/Setting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/State.cs → ...Charger.Model/Entities/TeslaMate/State.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Token.cs → ...Charger.Model/Entities/TeslaMate/Token.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
TeslaSolarCharger.Model/Entities/Update.cs → ...harger.Model/Entities/TeslaMate/Update.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
TeslaSolarCharger.Model/Entities/TeslaSolarCharger/ChargePrice.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger; | ||
|
||
public class ChargePrice | ||
{ | ||
public int Id { get; set; } | ||
public DateTime ValidSince { get; set; } | ||
public decimal SolarPrice { get; set; } | ||
public decimal GridPrice { get; set; } | ||
|
||
public List<HandledCharge> HandledCharges { get; set; } | ||
} |
16 changes: 16 additions & 0 deletions
16
TeslaSolarCharger.Model/Entities/TeslaSolarCharger/HandledCharge.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger; | ||
|
||
public class HandledCharge | ||
{ | ||
public int Id { get; set; } | ||
public int ChargingProcessId { get; set; } | ||
public int CarId { get; set; } | ||
public decimal? UsedGridEnergy { get; set; } | ||
public decimal? UsedSolarEnergy { get; set; } | ||
public decimal? CalculatedPrice { get; set; } | ||
public List<PowerDistribution> PowerDistributions { get; set; } = new(); | ||
|
||
|
||
public int ChargePriceId { get; set; } | ||
public ChargePrice ChargePrice { get; set; } | ||
} |
13 changes: 13 additions & 0 deletions
13
TeslaSolarCharger.Model/Entities/TeslaSolarCharger/PowerDistribution.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger; | ||
|
||
public class PowerDistribution | ||
{ | ||
public int Id { get; set; } | ||
public DateTime TimeStamp { get; set; } | ||
public int ChargingPower { get; set; } | ||
public int PowerFromGrid { get; set; } | ||
public float GridProportion { get; set; } | ||
|
||
public int HandledChargeId { get; set; } | ||
public HandledCharge HandledCharge { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
TeslaSolarCharger.Model/EntityFramework/TeslaSolarChargerContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using TeslaSolarCharger.Model.Contracts; | ||
using TeslaSolarCharger.Model.Entities.TeslaSolarCharger; | ||
|
||
namespace TeslaSolarCharger.Model.EntityFramework; | ||
|
||
public class TeslaSolarChargerContext : DbContext, ITeslaSolarChargerContext | ||
{ | ||
public DbSet<ChargePrice> ChargePrices { get; set; } = null!; | ||
public DbSet<HandledCharge> HandledCharges { get; set; } = null!; | ||
public DbSet<PowerDistribution> PowerDistributions { get; set; } = null!; | ||
|
||
public string DbPath { get; } | ||
|
||
public void RejectChanges() | ||
{ | ||
foreach (var entry in ChangeTracker.Entries()) | ||
{ | ||
switch (entry.State) | ||
{ | ||
case EntityState.Modified: | ||
case EntityState.Deleted: | ||
entry.State = EntityState.Modified; //Revert changes made to deleted entity. | ||
entry.State = EntityState.Unchanged; | ||
break; | ||
case EntityState.Added: | ||
entry.State = EntityState.Detached; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
public TeslaSolarChargerContext() | ||
{ | ||
} | ||
|
||
public TeslaSolarChargerContext(DbContextOptions<TeslaSolarChargerContext> options) | ||
: base(options) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
TeslaSolarCharger.Model/Migrations/20220907150318_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.