Split resource in Resource and resourceData + Add Audio ResourceType
This commit is contained in:
parent
390852ce4f
commit
cf2d7759de
@ -10,8 +10,8 @@ namespace Manager.Interfaces.DTO
|
|||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
public ResourceType type { get; set; }
|
public ResourceType type { get; set; }
|
||||||
public string label { get; set; }
|
public string label { get; set; }
|
||||||
public DateTime dateCreation { get; set; }
|
|
||||||
public string data { get; set; }
|
public string data { get; set; }
|
||||||
|
public DateTime dateCreation { get; set; }
|
||||||
public string instanceId { get; set; }
|
public string instanceId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,22 +27,18 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonElement("DateCreation")]
|
[BsonElement("DateCreation")]
|
||||||
public DateTime DateCreation { get; set; }
|
public DateTime DateCreation { get; set; }
|
||||||
|
|
||||||
[BsonElement("Data")]
|
|
||||||
[BsonRequired]
|
|
||||||
public string Data { get; set; }
|
|
||||||
|
|
||||||
[BsonElement("InstanceId")]
|
[BsonElement("InstanceId")]
|
||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string InstanceId { get; set; }
|
public string InstanceId { get; set; }
|
||||||
|
|
||||||
public ResourceDTO ToDTO(bool isExport = false)
|
public ResourceDTO ToDTO(string data = null) //
|
||||||
{
|
{
|
||||||
return new ResourceDTO()
|
return new ResourceDTO()
|
||||||
{
|
{
|
||||||
id = Id,
|
id = Id,
|
||||||
label = Label,
|
label = Label,
|
||||||
type = Type,
|
type = Type,
|
||||||
data = isExport ? Data : null,
|
data = data,
|
||||||
dateCreation = DateCreation,
|
dateCreation = DateCreation,
|
||||||
instanceId = InstanceId
|
instanceId = InstanceId
|
||||||
};
|
};
|
||||||
@ -54,6 +50,7 @@ namespace Manager.Interfaces.Models
|
|||||||
Image,
|
Image,
|
||||||
Video,
|
Video,
|
||||||
ImageUrl,
|
ImageUrl,
|
||||||
VideoUrl
|
VideoUrl,
|
||||||
|
Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
Manager.Interfaces/Models/ResourceData.cs
Normal file
31
Manager.Interfaces/Models/ResourceData.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Manager.Interfaces.DTO;
|
||||||
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Manager.Interfaces.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resource Information
|
||||||
|
/// </summary>
|
||||||
|
public class ResourceData
|
||||||
|
{
|
||||||
|
[BsonId]
|
||||||
|
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("Data")]
|
||||||
|
[BsonRequired]
|
||||||
|
public string Data { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("ResourceId")]
|
||||||
|
[BsonRequired]
|
||||||
|
public string ResourceId { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("InstanceId")]
|
||||||
|
[BsonRequired]
|
||||||
|
public string InstanceId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,17 +25,19 @@ namespace ManagerService.Controllers
|
|||||||
private ConfigurationDatabaseService _configurationService;
|
private ConfigurationDatabaseService _configurationService;
|
||||||
private SectionDatabaseService _sectionService;
|
private SectionDatabaseService _sectionService;
|
||||||
private ResourceDatabaseService _resourceService;
|
private ResourceDatabaseService _resourceService;
|
||||||
|
private ResourceDataDatabaseService _resourceDataService;
|
||||||
private DeviceDatabaseService _deviceService;
|
private DeviceDatabaseService _deviceService;
|
||||||
private readonly ILogger<ConfigurationController> _logger;
|
private readonly ILogger<ConfigurationController> _logger;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
public ConfigurationController(IConfiguration configuration, ILogger<ConfigurationController> logger, ConfigurationDatabaseService configurationService, SectionDatabaseService sectionService, ResourceDatabaseService resourceService, DeviceDatabaseService deviceService)
|
public ConfigurationController(IConfiguration configuration, ILogger<ConfigurationController> logger, ConfigurationDatabaseService configurationService, SectionDatabaseService sectionService, ResourceDatabaseService resourceService, ResourceDataDatabaseService resourceDataService, DeviceDatabaseService deviceService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
_sectionService = sectionService;
|
_sectionService = sectionService;
|
||||||
_resourceService = resourceService;
|
_resourceService = resourceService;
|
||||||
|
_resourceDataService = resourceDataService;
|
||||||
_deviceService = deviceService;
|
_deviceService = deviceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,19 +588,28 @@ namespace ManagerService.Controllers
|
|||||||
resource.Type = resourceExport.type;
|
resource.Type = resourceExport.type;
|
||||||
resource.Label = resourceExport.label;
|
resource.Label = resourceExport.label;
|
||||||
resource.DateCreation = resourceExport.dateCreation;
|
resource.DateCreation = resourceExport.dateCreation;
|
||||||
resource.Data = resourceExport.data;
|
//resource.Data = resourceExport.data;
|
||||||
|
|
||||||
|
ResourceData resourceData = new ResourceData();
|
||||||
|
resourceData.ResourceId = resourceExport.id;
|
||||||
|
resourceData.InstanceId = resourceExport.instanceId;
|
||||||
|
resourceData.Data = resourceExport.data;
|
||||||
|
|
||||||
if (!_resourceService.IsExist(resourceExport.id))
|
if (!_resourceService.IsExist(resourceExport.id))
|
||||||
_resourceService.Create(resource);
|
_resourceService.Create(resource);
|
||||||
|
|
||||||
|
if (!_resourceDataService.IsExist(resourceExport.id))
|
||||||
|
_resourceDataService.Create(resourceData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceDTO> addResourceToList(List<ResourceDTO> resourceDTOs, string resourceId) {
|
private List<ResourceDTO> addResourceToList(List<ResourceDTO> resourceDTOs, string resourceId) {
|
||||||
if (!resourceDTOs.Select(r => r.id).Contains(resourceId)) {
|
if (!resourceDTOs.Select(r => r.id).Contains(resourceId)) {
|
||||||
Resource resource = _resourceService.GetById(resourceId);
|
Resource resource = _resourceService.GetById(resourceId);
|
||||||
|
ResourceData resourceData = _resourceDataService.GetByResourceId(resourceId);
|
||||||
|
|
||||||
if (resource != null) {
|
if (resource != null && resourceData != null) {
|
||||||
resourceDTOs.Add(resource.ToDTO(true));
|
resourceDTOs.Add(resource.ToDTO(resourceData.Data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resourceDTOs;
|
return resourceDTOs;
|
||||||
|
|||||||
@ -26,14 +26,16 @@ namespace ManagerService.Controllers
|
|||||||
public class ResourceController : ControllerBase
|
public class ResourceController : ControllerBase
|
||||||
{
|
{
|
||||||
private ResourceDatabaseService _resourceService;
|
private ResourceDatabaseService _resourceService;
|
||||||
|
private ResourceDataDatabaseService _resourceDataService;
|
||||||
private SectionDatabaseService _sectionService;
|
private SectionDatabaseService _sectionService;
|
||||||
private ConfigurationDatabaseService _configurationService;
|
private ConfigurationDatabaseService _configurationService;
|
||||||
private readonly ILogger<ResourceController> _logger;
|
private readonly ILogger<ResourceController> _logger;
|
||||||
|
|
||||||
public ResourceController(ILogger<ResourceController> logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService)
|
public ResourceController(ILogger<ResourceController> logger, ResourceDatabaseService resourceService, ResourceDataDatabaseService resourceDataService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_resourceService = resourceService;
|
_resourceService = resourceService;
|
||||||
|
_resourceDataService = resourceDataService;
|
||||||
_sectionService = sectionService;
|
_sectionService = sectionService;
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
}
|
}
|
||||||
@ -51,7 +53,20 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
List<Resource> resources = _resourceService.GetAll(instanceId);
|
List<Resource> resources = _resourceService.GetAll(instanceId);
|
||||||
|
|
||||||
return new OkObjectResult(resources.Select(r => r.ToDTO(r.Type == ResourceType.ImageUrl)));
|
List<ResourceDTO> resourceDTOs = new List<ResourceDTO>();
|
||||||
|
foreach(var resource in resources)
|
||||||
|
{
|
||||||
|
ResourceDTO resourceDTO = new ResourceDTO();
|
||||||
|
resourceDTO = resource.ToDTO();
|
||||||
|
if(resource.Type == ResourceType.ImageUrl)
|
||||||
|
{
|
||||||
|
var resourceData = _resourceDataService.GetByResourceId(resource.Id);
|
||||||
|
resourceDTO.data = resourceData != null ? resourceData.Data : null;
|
||||||
|
}
|
||||||
|
resourceDTOs.Add(resourceDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(resourceDTOs);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -59,7 +74,6 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a specific resource
|
/// Get a specific resource
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -78,7 +92,15 @@ namespace ManagerService.Controllers
|
|||||||
if (resource == null)
|
if (resource == null)
|
||||||
throw new KeyNotFoundException("This resource was not found");
|
throw new KeyNotFoundException("This resource was not found");
|
||||||
|
|
||||||
return new OkObjectResult(resource.ToDTO(resource.Type == ResourceType.ImageUrl));
|
ResourceDTO resourceDTO = new ResourceDTO();
|
||||||
|
resourceDTO = resource.ToDTO();
|
||||||
|
if (resource.Type == ResourceType.ImageUrl)
|
||||||
|
{
|
||||||
|
var resourceData = _resourceDataService.GetByResourceId(resource.Id);
|
||||||
|
resourceDTO.data = resourceData != null ? resourceData.Data : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(resourceDTO);
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException ex)
|
catch (KeyNotFoundException ex)
|
||||||
{
|
{
|
||||||
@ -104,17 +126,18 @@ namespace ManagerService.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Resource resource = _resourceService.GetById(id);
|
Resource resource = _resourceService.GetById(id);
|
||||||
|
ResourceData resourceData = _resourceDataService.GetByResourceId(id);
|
||||||
|
|
||||||
if (resource == null)
|
if (resource == null || resourceData == null)
|
||||||
throw new KeyNotFoundException("This resource was not found");
|
throw new KeyNotFoundException("This resource was not found");
|
||||||
|
|
||||||
var file = Convert.FromBase64String(resource.Data);
|
var file = Convert.FromBase64String(resourceData.Data);
|
||||||
|
|
||||||
if (resource.Type == ResourceType.Image)
|
if (resource.Type == ResourceType.Image)
|
||||||
{
|
{
|
||||||
return new FileContentResult(file, "image/png");
|
return new FileContentResult(file, "image/png");
|
||||||
}
|
}
|
||||||
if (resource.Type == ResourceType.Video)
|
if (resource.Type == ResourceType.Video || resource.Type == ResourceType.Audio)
|
||||||
{
|
{
|
||||||
return new FileContentResult(file, "application/octet-stream");
|
return new FileContentResult(file, "application/octet-stream");
|
||||||
}
|
}
|
||||||
@ -145,6 +168,7 @@ namespace ManagerService.Controllers
|
|||||||
if (label == null || type == null || instanceId == null)
|
if (label == null || type == null || instanceId == null)
|
||||||
throw new ArgumentNullException("One of resource params is null");
|
throw new ArgumentNullException("One of resource params is null");
|
||||||
|
|
||||||
|
var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type);
|
||||||
List<Resource> resources = new List<Resource>();
|
List<Resource> resources = new List<Resource>();
|
||||||
|
|
||||||
foreach (var file in Request.Form.Files)
|
foreach (var file in Request.Form.Files)
|
||||||
@ -152,24 +176,36 @@ namespace ManagerService.Controllers
|
|||||||
if (file.Length > 0)
|
if (file.Length > 0)
|
||||||
{
|
{
|
||||||
var stringResult = "";
|
var stringResult = "";
|
||||||
if (file.Length > 0)
|
double fileSizeibMbs = (double) ((double)file.Length) / (1024*1024);
|
||||||
|
if (fileSizeibMbs <= 2.01)
|
||||||
{
|
{
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
file.CopyTo(ms);
|
file.CopyTo(ms);
|
||||||
var fileBytes = ms.ToArray();
|
var fileBytes = ms.ToArray();
|
||||||
|
if (resourceType == ResourceType.Image) {
|
||||||
|
fileBytes = AddWatermark(fileBytes);
|
||||||
|
}
|
||||||
stringResult = Convert.ToBase64String(fileBytes);
|
stringResult = Convert.ToBase64String(fileBytes);
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
throw new FileLoadException(message: "Fichier inexistant ou trop volumineux (max 2Mb)");
|
||||||
}
|
}
|
||||||
// Todo add some verification ?
|
// Todo add some verification ?
|
||||||
Resource resource = new Resource();
|
Resource resource = new Resource();
|
||||||
resource.Label = label;
|
resource.Label = label;
|
||||||
resource.Type = (ResourceType)Enum.Parse(typeof(ResourceType), type);
|
resource.Type = resourceType;
|
||||||
resource.DateCreation = DateTime.Now;
|
resource.DateCreation = DateTime.Now;
|
||||||
resource.Data = stringResult;
|
|
||||||
resource.InstanceId = instanceId;
|
resource.InstanceId = instanceId;
|
||||||
Resource resourceCreated = _resourceService.Create(resource);
|
Resource resourceCreated = _resourceService.Create(resource);
|
||||||
resources.Add(resourceCreated);
|
resources.Add(resourceCreated);
|
||||||
|
|
||||||
|
ResourceData resourceData = new ResourceData();
|
||||||
|
resourceData.Data = stringResult;
|
||||||
|
resourceData.ResourceId = resourceCreated.Id;
|
||||||
|
resourceData.InstanceId = stringResult;
|
||||||
|
ResourceData resourceDataCreated = _resourceDataService.Create(resourceData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(resources.Select(r => r.ToDTO()));
|
return Ok(resources.Select(r => r.ToDTO()));
|
||||||
@ -178,6 +214,10 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
return new BadRequestObjectResult(ex.Message) { };
|
return new BadRequestObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
|
catch (FileLoadException ex)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult(ex.Message) { };
|
||||||
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
return new ConflictObjectResult(ex.Message) { };
|
return new ConflictObjectResult(ex.Message) { };
|
||||||
@ -188,6 +228,37 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] AddWatermark(Byte[] bytes)
|
||||||
|
{
|
||||||
|
byte[] convertedToBytes;
|
||||||
|
|
||||||
|
using (MemoryStream originalImageMemoryStream = new MemoryStream(bytes))
|
||||||
|
{
|
||||||
|
using (Image image = Image.FromStream(originalImageMemoryStream))
|
||||||
|
{
|
||||||
|
Font font = new Font("Arial", 25, FontStyle.Italic, GraphicsUnit.Pixel);
|
||||||
|
Color color = Color.DarkBlue;
|
||||||
|
Point point = new Point(image.Width /2, (int)Math.Round(image.Height - image.Height * 0.1));
|
||||||
|
SolidBrush brush = new SolidBrush(color);
|
||||||
|
using (Graphics graphics = Graphics.FromImage(image))
|
||||||
|
{
|
||||||
|
StringFormat stringFormat = new StringFormat();
|
||||||
|
stringFormat.Alignment = StringAlignment.Center;
|
||||||
|
stringFormat.LineAlignment = StringAlignment.Center;
|
||||||
|
graphics.DrawString("fortsaintheribert.be", font, brush, point, stringFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (MemoryStream updatedImageMemorySteam = new MemoryStream())
|
||||||
|
{
|
||||||
|
image.Save(updatedImageMemorySteam, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||||
|
convertedToBytes = updatedImageMemorySteam.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertedToBytes;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new resource
|
/// Create a new resource
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -210,12 +281,12 @@ namespace ManagerService.Controllers
|
|||||||
resource.Label = newResource.label;
|
resource.Label = newResource.label;
|
||||||
resource.Type = newResource.type;
|
resource.Type = newResource.type;
|
||||||
resource.DateCreation = DateTime.Now;
|
resource.DateCreation = DateTime.Now;
|
||||||
resource.Data = newResource.data;
|
//resource.Data = newResource.data;
|
||||||
resource.InstanceId = newResource.instanceId;
|
resource.InstanceId = newResource.instanceId;
|
||||||
|
|
||||||
Resource resourceCreated = _resourceService.Create(resource);
|
Resource resourceCreated = _resourceService.Create(resource);
|
||||||
|
|
||||||
return new OkObjectResult(resourceCreated.ToDTO(resource.Type == ResourceType.ImageUrl));
|
return new OkObjectResult(resourceCreated.ToDTO()); // WITHOUT DATA
|
||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
{
|
{
|
||||||
@ -257,7 +328,7 @@ namespace ManagerService.Controllers
|
|||||||
resource.InstanceId = updatedResource.instanceId;
|
resource.InstanceId = updatedResource.instanceId;
|
||||||
resource.Label = updatedResource.label;
|
resource.Label = updatedResource.label;
|
||||||
resource.Type = updatedResource.type;
|
resource.Type = updatedResource.type;
|
||||||
resource.Data = updatedResource.data;
|
//resource.Data = updatedResource.data; // NOT ALLOWED
|
||||||
|
|
||||||
Resource resourceModified = _resourceService.Update(updatedResource.id, resource);
|
Resource resourceModified = _resourceService.Update(updatedResource.id, resource);
|
||||||
|
|
||||||
@ -295,6 +366,7 @@ namespace ManagerService.Controllers
|
|||||||
throw new ArgumentNullException("Resource param is null");
|
throw new ArgumentNullException("Resource param is null");
|
||||||
|
|
||||||
var ressource = _resourceService.GetById(id);
|
var ressource = _resourceService.GetById(id);
|
||||||
|
var ressourceData = _resourceDataService.GetByResourceId(id);
|
||||||
if (ressource == null)
|
if (ressource == null)
|
||||||
throw new KeyNotFoundException("Resource does not exist");
|
throw new KeyNotFoundException("Resource does not exist");
|
||||||
|
|
||||||
@ -389,6 +461,10 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
_resourceService.Remove(id);
|
_resourceService.Remove(id);
|
||||||
|
if (ressourceData != null)
|
||||||
|
{
|
||||||
|
_resourceDataService.Remove(ressourceData.Id);
|
||||||
|
}
|
||||||
|
|
||||||
return new ObjectResult("The resource has been deleted") { StatusCode = 202 };
|
return new ObjectResult("The resource has been deleted") { StatusCode = 202 };
|
||||||
|
|
||||||
|
|||||||
64
ManagerService/Services/ResourceDataDatabaseService.cs
Normal file
64
ManagerService/Services/ResourceDataDatabaseService.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Manager.Interfaces.Models;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
|
||||||
|
namespace Manager.Services
|
||||||
|
{
|
||||||
|
public class ResourceDataDatabaseService
|
||||||
|
{
|
||||||
|
private readonly IMongoCollection<ResourceData> _ResourcesData;
|
||||||
|
|
||||||
|
public ResourceDataDatabaseService(IConfiguration config)
|
||||||
|
{
|
||||||
|
var client = new MongoClient(config.GetConnectionString("TabletDb"));
|
||||||
|
var database = client.GetDatabase("TabletDb");
|
||||||
|
_ResourcesData = database.GetCollection<ResourceData>("ResourcesData");
|
||||||
|
}
|
||||||
|
public List<ResourceData> GetAll(string instanceId)
|
||||||
|
{
|
||||||
|
return _ResourcesData.Find(r => r.InstanceId == instanceId).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceData GetById(string id)
|
||||||
|
{
|
||||||
|
return _ResourcesData.Find<ResourceData>(r => r.Id == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceData GetByResourceId(string id)
|
||||||
|
{
|
||||||
|
return _ResourcesData.Find<ResourceData>(r => r.ResourceId == id).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExist(string id)
|
||||||
|
{
|
||||||
|
return _ResourcesData.Find<ResourceData>(r => r.Id == id).FirstOrDefault() != null ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExistResourceId(string id)
|
||||||
|
{
|
||||||
|
return _ResourcesData.Find<ResourceData>(r => r.ResourceId == id).FirstOrDefault() != null ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceData Create(ResourceData resource)
|
||||||
|
{
|
||||||
|
_ResourcesData.InsertOne(resource);
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceData Update(string id, ResourceData resourceIn)
|
||||||
|
{
|
||||||
|
_ResourcesData.ReplaceOne(r => r.Id == id, resourceIn);
|
||||||
|
return resourceIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string id)
|
||||||
|
{
|
||||||
|
_ResourcesData.DeleteOne(r => r.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -139,6 +139,7 @@ namespace ManagerService
|
|||||||
services.AddScoped<SectionDatabaseService>();
|
services.AddScoped<SectionDatabaseService>();
|
||||||
services.AddScoped<ConfigurationDatabaseService>();
|
services.AddScoped<ConfigurationDatabaseService>();
|
||||||
services.AddScoped<ResourceDatabaseService>();
|
services.AddScoped<ResourceDatabaseService>();
|
||||||
|
services.AddScoped<ResourceDataDatabaseService>();
|
||||||
services.AddScoped<LanguageInit>();
|
services.AddScoped<LanguageInit>();
|
||||||
services.AddScoped<DeviceDatabaseService>();
|
services.AddScoped<DeviceDatabaseService>();
|
||||||
services.AddScoped<InstanceDatabaseService>();
|
services.AddScoped<InstanceDatabaseService>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user