Executed code-cleanup on solution

This commit is contained in:
Samuele Locatelli
2020-06-19 19:28:07 +02:00
parent 5d3edf46c6
commit 5b2841c01b
166 changed files with 1733 additions and 2227 deletions
@@ -1,10 +1,8 @@
using Thermo.Active.Model.DatabaseModels;
using Thermo.Active.Model.DTOModels;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Thermo.Active.Model.DatabaseModels;
using Thermo.Active.Model.DTOModels;
using static Thermo.Active.Model.Constants;
namespace Thermo.Active.Database.Controllers
@@ -30,12 +28,12 @@ namespace Thermo.Active.Database.Controllers
public void UpdateQueue()
{
dbCtx.Queue.RemoveRange(dbCtx.Queue);
var dbRows = new List<QueueItemsModel>();
foreach (var item in PartProgramQueue)
{
// Create database model
dbRows =item.Value.Select(x => new QueueItemsModel()
dbRows = item.Value.Select(x => new QueueItemsModel()
{
Id = x.Id,
AbsolutePath = x.AbsolutePath,
@@ -49,7 +47,7 @@ namespace Thermo.Active.Database.Controllers
// Add to db
dbCtx.Queue.AddRange(dbRows);
}
dbCtx.SaveChanges();
}
@@ -65,14 +63,14 @@ namespace Thermo.Active.Database.Controllers
item.RemainingReps = reps;
dbCtx.SaveChanges();
}
public void DeleteItem(int processId, int id)
{
QueueItemsModel item = dbCtx.Queue.FirstOrDefault(x => x.Id == id && x.Process == processId);
if(item == null)
if (item == null)
return;
dbCtx.Queue.Remove(item);
@@ -84,7 +82,7 @@ namespace Thermo.Active.Database.Controllers
{
var dbQueue = dbCtx.Queue.ToList();
bool foundData = false;
foreach(var entity in dbQueue)
foreach (var entity in dbQueue)
{
// Check if process queue exists
if (!PartProgramQueue.ContainsKey(entity.Process))
@@ -111,13 +109,13 @@ namespace Thermo.Active.Database.Controllers
QueueRunningIndexes[entity.Process] = entity.Id - 1;
}
}
public void UpdateQueueIdsAndSave(int processId)
{
// Fix new ids
for (int i = 0; i < PartProgramQueue[processId].Count(); i++)
PartProgramQueue[processId][i].Id = i + 1;
UpdateQueue();
}
}