internal static class BaseControllerHelpers { public static TEditDto ConvertToEntity(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; } }