blob: 3969818667f50df0a6fd6e316883669b296e3947 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using Models.DTOs;
using System.Reflection;
namespace Models.Classes
{
public static class Mapper
{
/// <summary>
/// Mapps UserDTO to a User
/// </summary>
/// <param name="userDTO">UserDTO that is going to be mapped</param>
/// <returns>Mapped User</returns>
public static User UserDtoToUser(UserDTO userDTO)
{
User user = new User();
foreach(PropertyInfo property in user.GetType().GetProperties())
{
var neshto = property.GetValue(userDTO, null);
property.SetValue(user, neshto, null);
}
return user;
}
}
}
|