Redid some of the surface editor and started working on layout saving

This commit is contained in:
SpoinkyNL committed 2019-09-18 22:26:10 +02:00
1 parent 81294eef8f
commit 71f53c0833
48 files changed
+1012 -107

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ namespace Artemis.Storage.Entities
public string LedName { get; set; }
public string LimitedToDevice { get; set; }
public int LayerId { get; set; }
public string LayerId { get; set; }
public virtual LayerEntity Layer { get; set; }
}
}
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace Artemis.Storage.Entities
{
public class SurfaceDeviceEntity
{
[Key]
public string Guid { get; set; }
public int DeviceId { get; set; }
public string DeviceName { get; set; }
public string DeviceModel { get; set; }
public string DeviceManufacturer { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Rotation { get; set; }
public string SurfaceId { get; set; }
public virtual SurfaceEntity Surface { get; set; }
}
}
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Artemis.Storage.Entities
{
public class SurfaceEntity
{
[Key]
public string Guid { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
public virtual ICollection<SurfacePositionEntity> SurfacePositions { get; set; }
}
}
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace Artemis.Storage.Entities
{
public class SurfacePositionEntity
{
[Key]
public string Guid { get; set; }
public int DeviceId { get; set; }
public string DeviceName { get; set; }
public string DeviceModel { get; set; }
public string DeviceManufacturer { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Rotation { get; set; }
public string SurfaceId { get; set; }
public virtual SurfaceEntity Surface { get; set; }
}
}
@@ -1,6 +0,0 @@
namespace Artemis.Storage.Repositories
{
public interface IRepository
{
}
}
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IPluginSettingRepository : IRepository
{
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IProfileRepository : IRepository
{
IQueryable<ProfileEntity> GetAll();
Task<IList<ProfileEntity>> GetByPluginGuidAsync(Guid pluginGuid);
Task<ProfileEntity> GetByGuidAsync(string guid);
void Save();
Task SaveAsync();
}
}
@@ -0,0 +1,6 @@
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IRepository
{
}
}
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Artemis.Storage.Entities;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories.Interfaces
{
public interface ISettingRepository : IRepository
{
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
namespace Artemis.Storage.Repositories.Interfaces
{
public interface ISurfaceRepository : IRepository
{
void Add(SurfaceEntity surfaceEntity);
SurfaceEntity Get(string name);
Task<SurfaceEntity> GetAsync(string name);
List<SurfaceEntity> GetAll();
Task<List<SurfaceEntity>> GetAllAsync();
void Save();
Task SaveAsync();
}
}
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
using Artemis.Storage.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Artemis.Storage.Repositories
@@ -3,11 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
using Artemis.Storage.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Artemis.Storage.Repositories
{
public class ProfileRepository
public class ProfileRepository : IProfileRepository
{
private readonly StorageContext _dbContext;
@@ -32,6 +33,11 @@ namespace Artemis.Storage.Repositories
return await _dbContext.Profiles.FirstOrDefaultAsync(p => p.Guid == guid);
}
public void Save()
{
_dbContext.SaveChanges();
}
public async Task SaveAsync()
{
await _dbContext.SaveChangesAsync();
@@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
using Artemis.Storage.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Artemis.Storage.Repositories
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Storage.Entities;
using Artemis.Storage.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Artemis.Storage.Repositories
{
public class SurfaceRepository : ISurfaceRepository
{
private readonly StorageContext _dbContext;
internal SurfaceRepository()
{
_dbContext = new StorageContext();
_dbContext.Database.EnsureCreated();
}
public void Add(SurfaceEntity surfaceEntity)
{
_dbContext.Surfaces.Add(surfaceEntity);
}
public SurfaceEntity Get(string name)
{
return _dbContext.Surfaces.Include(s => s.SurfacePositions).FirstOrDefault(p => p.Name == name);
}
public async Task<SurfaceEntity> GetAsync(string name)
{
return await _dbContext.Surfaces.Include(s => s.SurfacePositions).FirstOrDefaultAsync(p => p.Name == name);
}
public List<SurfaceEntity> GetAll()
{
return _dbContext.Surfaces.Include(s => s.SurfacePositions).ToList();
}
public async Task<List<SurfaceEntity>> GetAllAsync()
{
return await _dbContext.Surfaces.Include(s => s.SurfacePositions).ToListAsync();
}
public void Save()
{
_dbContext.SaveChanges();
}
public async Task SaveAsync()
{
await _dbContext.SaveChangesAsync();
}
}
}
+1
View File
@@ -10,6 +10,7 @@ namespace Artemis.Storage
{
public DbSet<ProfileEntity> Profiles { get; set; }
public DbSet<SettingEntity> Settings { get; set; }
public DbSet<SurfaceEntity> Surfaces { get; set; }
public DbSet<PluginSettingEntity> PluginSettings { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)