using ManagerService.DTOs; using System; using System.ComponentModel.DataAnnotations; namespace ManagerService.Data { /// /// Instance Information /// public class Instance { [Key] [Required] public string Id { get; set; } [Required] public string Name { get; set; } // UNIQUE !.. public DateTime DateCreation { get; set; } public string PinCode { get; set; } public bool IsPushNotification { get; set; } public bool IsStatistic { get; set; } public bool IsMobile { get; set; } public bool IsTablet { get; set; } public bool IsVR { get; set; } public InstanceDTO ToDTO() { return new InstanceDTO() { id = Id, name = Name, dateCreation = DateCreation, pinCode = PinCode, isPushNotification = IsPushNotification, isStatistic = IsStatistic, isMobile = IsMobile, isTablet = IsTablet, isVR = IsVR, }; } public Instance FromDTO(InstanceDTO instanceDTO) { Name = instanceDTO.name; DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(); PinCode = instanceDTO.pinCode; IsPushNotification = instanceDTO.isPushNotification; IsStatistic = instanceDTO.isStatistic; IsMobile = instanceDTO.isMobile; IsTablet = instanceDTO.isTablet; IsVR = instanceDTO.isVR; return this; } } }