| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace GreenTree.Nachtragsmanagement.Web.Models.Config
- {
- public class ConfigItemDataModel
- {
- public static Dictionary<string, string> FullTypeTranslations = new Dictionary<string, string>
- {
- { typeof(System.String).FullName, "Text" },
- { typeof(System.Int32).FullName, "Ganze Zahl" },
- { typeof(System.Int64).FullName, "Große ganze Zahl" },
- { typeof(System.Boolean).FullName, "Wahrheitswert" },
- { typeof(System.Double).FullName, "Kommazahl" },
- { typeof(System.DateTime).FullName, "Datum" },
- { typeof(System.Drawing.Color).FullName, "Farbe" },
- };
- public int Id { get; set; }
- public string Name { get; set; }
- public string TypeFullName { get; set; }
- public string TypeDescription { get; set; }
- public string Value { get; set; }
- public string Description { get; set; }
- public static ConfigItemDataModel FromConfigItem(Core.Domain.Config.ConfigItem configItemEntity, bool newWhenIsNull)
- {
- if (configItemEntity == null && newWhenIsNull)
- return new ConfigItemDataModel
- {
- Id = -1
- };
- if (configItemEntity == null && !newWhenIsNull)
- throw new ArgumentNullException("configItemEntity", "Cannot create ConfigItemDataModel from NULL configItem entity.");
- return new ConfigItemDataModel
- {
- Id = configItemEntity.Id,
- Name = configItemEntity.Name,
- TypeFullName = configItemEntity.TypeFullName,
- TypeDescription = FullTypeTranslations[configItemEntity.TypeFullName],
- Value = configItemEntity.Value,
- Description = configItemEntity.Description
- };
- }
- public Core.Domain.Config.ConfigItem ToConfigItem()
- {
- return new Core.Domain.Config.ConfigItem
- {
- Id = this.Id,
- Name = this.Name,
- TypeFullName = this.TypeFullName,
- Value = this.Value,
- Description = this.Description
- };
- }
- }
- }
|