|
|
|
@ -1,16 +0,0 @@ |
|
|
|
|
internal static class BaseControllerHelpers |
|
|
|
|
{ |
|
|
|
|
public static TEditDto ConvertToEntity<TEditDto>(object obj) where TEditDto : new() |
|
|
|
|
{ |
|
|
|
|
TEditDto entity = new TEditDto(); |
|
|
|
|
foreach (var property in typeof(TEditDto).GetProperties()) |
|
|
|
|
{ |
|
|
|
|
var value = obj.GetType().GetProperty(property.Name)?.GetValue(obj, null); |
|
|
|
|
if (value != null) |
|
|
|
|
{ |
|
|
|
|
property.SetValue(entity, Convert.ChangeType(value, property.PropertyType), null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
} |
|
|
|
|
} |