53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using ManagerService.DTOs;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace ManagerService.Data
|
|
{
|
|
/// <summary>
|
|
/// Instance Information
|
|
/// </summary>
|
|
public class Instance
|
|
{
|
|
[Key]
|
|
[Required]
|
|
/*[BsonId]
|
|
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/
|
|
public string Id { get; set; }
|
|
|
|
/*[BsonElement("Name")]
|
|
[BsonRequired]*/
|
|
[Required]
|
|
public string Name { get; set; } // UNIQUE !..
|
|
|
|
/*[BsonElement("DateCreation")]*/
|
|
public DateTime DateCreation { get; set; }
|
|
|
|
/*[BsonElement("PinCode")]*/
|
|
public string PinCode { get; set; }
|
|
|
|
public InstanceDTO ToDTO()
|
|
{
|
|
return new InstanceDTO()
|
|
{
|
|
id = Id,
|
|
name = Name,
|
|
dateCreation = DateCreation,
|
|
pinCode = PinCode
|
|
};
|
|
}
|
|
|
|
public Instance FromDTO(InstanceDTO instanceDTO)
|
|
{
|
|
return new Instance()
|
|
{
|
|
Id = instanceDTO.id,
|
|
Name = instanceDTO.name,
|
|
DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(),
|
|
PinCode = instanceDTO.pinCode
|
|
};
|
|
}
|
|
|
|
}
|
|
}
|