Added maxRight/Left
This commit is contained in:
@@ -142,8 +142,8 @@ namespace Step.Database.Controllers
|
||||
.Shanks
|
||||
.Include("Tools")
|
||||
.ToList();
|
||||
|
||||
// Populate db shanks
|
||||
|
||||
// Populate dto shanks
|
||||
List<DTONcShankModel> dtoShanks = dbShanks
|
||||
.Select(x => (DTONcShankModel)x)
|
||||
.ToList();
|
||||
@@ -151,6 +151,23 @@ namespace Step.Database.Controllers
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public List<DTONcShankModel> GetShanksWithSpace()
|
||||
{
|
||||
// Populate nks
|
||||
List<DTONcShankModel> dtoShanks = GetShanks();
|
||||
|
||||
// Calculate & set space occupied for each shank
|
||||
foreach(var shank in dtoShanks)
|
||||
{
|
||||
GetShankMaxSpaceOccupied(shank.Id, out int maxRight, out int maxLeft);
|
||||
|
||||
shank.MaxRight = maxRight;
|
||||
shank.MaxLeft = maxLeft;
|
||||
}
|
||||
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public DTONcShankModel GetShank(int shankId)
|
||||
{
|
||||
// Get shank from database
|
||||
@@ -183,6 +200,15 @@ namespace Step.Database.Controllers
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void GetShankMaxSpaceOccupied(int shankId, out int maxRight, out int maxLeft)
|
||||
{
|
||||
// Get families
|
||||
List<DbNcFamilyModel> families = FindFamiliesByShankId(shankId);
|
||||
// Find max
|
||||
maxRight = families.Max(x => x.RightSize);
|
||||
maxLeft = families.Max(x => x.LeftSize);
|
||||
}
|
||||
|
||||
public List<DTONcMagazinePositionModel> GetMagazinePositions(byte magId)
|
||||
{
|
||||
// Get only magazine positions that match with magazineId
|
||||
@@ -214,7 +240,7 @@ namespace Step.Database.Controllers
|
||||
|
||||
public List<DTONcShankModel> GetMountedShanks(int magazineId)
|
||||
{
|
||||
List<DTONcShankModel> dtoShanks = GetShanks()
|
||||
List<DTONcShankModel> dtoShanks = GetShanksWithSpace()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.ToList();
|
||||
|
||||
@@ -232,7 +258,7 @@ namespace Step.Database.Controllers
|
||||
|
||||
public List<DTONcShankModel> GetAvailableShanks()
|
||||
{
|
||||
List<DTONcShankModel> dtoShanks = GetShanks()
|
||||
List<DTONcShankModel> dtoShanks = GetShanksWithSpace()
|
||||
.Where(x => x.MagazineId == null)
|
||||
.ToList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user