| | | 1 | | using SVETA.Api.Helpers; |
| | | 2 | | using System; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Linq; |
| | | 5 | | using System.Text; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using WinSolutions.Sveta.Server.Data.DataModel.Entities; |
| | | 8 | | using System.ComponentModel.DataAnnotations; |
| | | 9 | | using SVETA.Api.Validation; |
| | | 10 | | |
| | | 11 | | namespace SVETA.Api.Data.DTO |
| | | 12 | | { |
| | | 13 | | public class ConfigurationResponseDTO |
| | | 14 | | { |
| | | 15 | | public ConfigurationResponseDTO() { } |
| | | 16 | | public ConfigurationResponseDTO(Configuration data) |
| | | 17 | | { |
| | | 18 | | Id = data.Id; |
| | | 19 | | Section = data.Section; |
| | | 20 | | Key = data.Key; |
| | | 21 | | Encrypted = data.Encrypted; |
| | | 22 | | ValueType = new ConfigurationValueTypeDTO(data.ValueType); |
| | | 23 | | Value = data.Encrypted ? SymmetricCrypto.DecryptData(Convert.FromBase64String(data.Value)) : data.Value; |
| | | 24 | | Description = data.Description; |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | public long Id { get; set; } |
| | | 28 | | public string Section { get; set; } |
| | | 29 | | public string Key { get; set; } |
| | | 30 | | public bool Encrypted { get; set; } |
| | | 31 | | public ConfigurationValueTypeDTO ValueType { get; set; } |
| | | 32 | | public string Value { get; set; } |
| | | 33 | | public string Description { get; set; } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | public class ConfigurationValueTypeDTO |
| | | 37 | | { |
| | 0 | 38 | | public ConfigurationValueTypeDTO() { } |
| | 0 | 39 | | public ConfigurationValueTypeDTO(ConfigurationsDataType data) |
| | 0 | 40 | | { |
| | 0 | 41 | | Id = data.Id; |
| | 0 | 42 | | Name = data.Name; |
| | 0 | 43 | | } |
| | 0 | 44 | | public long Id { get; set; } |
| | 0 | 45 | | public string Name { get; set; } |
| | | 46 | | } |
| | | 47 | | public class ConfigurationRequestDTO |
| | | 48 | | { |
| | | 49 | | public string Section { get; set; } |
| | | 50 | | [Required (ErrorMessage = "Название ключа не может быть пустым")] |
| | | 51 | | public string Key { get; set; } |
| | | 52 | | public bool Encrypted { get; set; } |
| | | 53 | | [DigitValidate (CanBeZero = false, CanBeNegative = true)] |
| | | 54 | | [Display(Name = "Тип значения")] |
| | | 55 | | public long ValueTypeId { get; set; } |
| | | 56 | | [Required(ErrorMessage = "Значение ключа не может быть пустым")] |
| | | 57 | | public string Value { get; set; } |
| | | 58 | | public string Description { get; set; } |
| | | 59 | | } |
| | | 60 | | } |