Fix maintenance ID
This commit is contained in:
@@ -77,6 +77,7 @@ namespace Step.Database.Controllers
|
||||
{
|
||||
MaintenanceModel dbMaint = new MaintenanceModel()
|
||||
{
|
||||
MaintenanceId = GetUserMaintenanceId(dbCtx.Maintenances),
|
||||
CreationDate = DateTime.Now,
|
||||
CounterId = 0,
|
||||
Interval = newMaint.Interval,
|
||||
@@ -97,6 +98,16 @@ namespace Step.Database.Controllers
|
||||
return dbMaint;
|
||||
}
|
||||
|
||||
private int GetUserMaintenanceId(IEnumerable<MaintenanceModel> maintenances)
|
||||
{
|
||||
int max = maintenances.Select(x => x.MaintenanceId).Max();
|
||||
// If there aren't user maintenance return 100
|
||||
if (max < 100)
|
||||
return 100;
|
||||
else
|
||||
return max + 1;
|
||||
}
|
||||
|
||||
public MaintenanceModel Update(int maintenanceId, DTOUpdateMaintenanceModel newMaint)
|
||||
{
|
||||
MaintenanceModel dbMaint = FindById(maintenanceId);
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -13,7 +13,7 @@ namespace Step.Database.Migrations
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201808031122175_InitMigration"; }
|
||||
get { return "201809181022557_InitMigration"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
+16
-1
@@ -172,7 +172,7 @@ namespace Step.Database.Migrations
|
||||
"dbo.maintenance",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
id = c.Int(nullable: false),
|
||||
intervall = c.Double(),
|
||||
deadline = c.DateTime(nullable: false, precision: 0),
|
||||
type = c.Int(nullable: false),
|
||||
@@ -217,6 +217,20 @@ namespace Step.Database.Migrations
|
||||
.ForeignKey("dbo.maintenance", t => t.maintenance, cascadeDelete: true)
|
||||
.Index(t => t.maintenance);
|
||||
|
||||
CreateTable(
|
||||
"dbo.queue",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false),
|
||||
process = c.Int(nullable: false),
|
||||
part_program_name = c.String(unicode: false),
|
||||
reps = c.Int(nullable: false),
|
||||
remaining_reps = c.Int(nullable: false),
|
||||
absolute_path = c.String(unicode: false),
|
||||
status = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => new { t.id, t.process });
|
||||
|
||||
CreateTable(
|
||||
"dbo.session",
|
||||
c => new
|
||||
@@ -259,6 +273,7 @@ namespace Step.Database.Migrations
|
||||
DropIndex("dbo.tool", new[] { "shank_id" });
|
||||
DropIndex("dbo.tool", new[] { "family_id" });
|
||||
DropTable("dbo.session");
|
||||
DropTable("dbo.queue");
|
||||
DropTable("dbo.performed_maintenance");
|
||||
DropTable("dbo.maintenance_note");
|
||||
DropTable("dbo.maintenance");
|
||||
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@ namespace Step.Model.DatabaseModels
|
||||
public class MaintenanceModel
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
[Column("id")]
|
||||
public int MaintenanceId { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user