// private static string GenerateCustomDateMethods(IEnumerable<LocationTypeProperty> CustomProps) // { // var classMethod = new StringBuilder(); // classMethod.Append( // @" public DateTime GetProperty(string Alias) // { // switch (Alias) // { // "); // foreach (var prop in CustomProps) // { // classMethod.Append(string.Format( // @" // case ""{0}"": // return this.{0}; // break; // ", prop.Alias)); // } // classMethod.Append( // @" // default: // return DateTime.MinValue; // } // } // "); // return classMethod.ToString(); // } // private static string GenerateCustomIntegerMethods(IEnumerable<LocationTypeProperty> CustomProps) // { // var classMethod = new StringBuilder(); // classMethod.Append( // @" public Integer GetProperty(string Alias) // { // switch (Alias) // { // "); // foreach (var prop in CustomProps) // { // classMethod.Append(string.Format( // @" // case ""{0}"": // return this.{0}; // break; // ", prop.Alias)); // } // classMethod.Append( // @" // default: // return 0; // } // } // "); // return classMethod.ToString(); // } private static string FormatCustomProperty(LocationTypeProperty CustomProperty) { var classProp = new StringBuilder(); switch (CustomProperty.DataType.DatabaseType) { case CmsDataType.DbType.Date: classProp.Append( string.Format( @" [FieldConverter(ConverterKind.Date, ""MMddyyyy"")] public DateTime {0}; ", CustomProperty.Alias)); break; case CmsDataType.DbType.Integer: if (CustomProperty.DataType.PropertyEditorAlias == "Umbraco.TrueFalse") { classProp.Append( string.Format( @" [FieldNullValue(typeof(bool), ""False"")] [FieldConverter(ConverterKind.Boolean)] public bool {0}; ", CustomProperty.Alias)); } else { classProp.Append( string.Format( @" [FieldNullValue(typeof(int), ""0"")] public int {0}; ", CustomProperty.Alias)); } break; default: classProp.Append( string.Format( @" [FieldNullValue(typeof(string), """")] [FieldQuoted('""', QuoteMode.OptionalForBoth)] public string {0}; ", CustomProperty.Alias)); break; } return(classProp.ToString()); }
public LocationTypePropertyDto ToLocationTypePropertyDto(LocationTypeProperty entity) { var dto = new LocationTypePropertyDto() { Key = entity.Key, Alias = entity.Alias, Name = entity.Name, DataTypeId = entity.DataTypeId, LocationTypeKey = entity.LocationTypeKey, SortOrder = entity.SortOrder, UpdateDate = entity.UpdateDate, CreateDate = entity.CreateDate, IsDefaultProp = entity.IsDefaultProp }; return(dto); }
public LocationTypeProperty ToLocationTypePropertyEntity(LocationTypePropertyDto dto) { var Entity = new LocationTypeProperty() { Key = dto.Key, Alias = dto.Alias, Name = dto.Name, DataTypeId = dto.DataTypeId, DataType = this.GetDataType(dto.DataTypeId), LocationTypeKey = dto.LocationTypeKey, SortOrder = dto.SortOrder, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate, IsDefaultProp = dto.IsDefaultProp }; return(Entity); }