view binding converters
This commit is contained in:
parent
c3dd4384ff
commit
51d26c58d7
25
Contracts/Converters/RoleConverter.cs
Normal file
25
Contracts/Converters/RoleConverter.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.Converters
|
||||||
|
{
|
||||||
|
public static class RoleConverter
|
||||||
|
{
|
||||||
|
public static RoleViewModel ToView(RoleBindingModel model) => new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
};
|
||||||
|
|
||||||
|
public static RoleBindingModel ToBinding(RoleViewModel model) => new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
33
Contracts/Converters/UserConverter.cs
Normal file
33
Contracts/Converters/UserConverter.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.Converters
|
||||||
|
{
|
||||||
|
public static class UserConverter
|
||||||
|
{
|
||||||
|
public static UserViewModel ToView(UserBindingModel model) => new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
FirstName = model.FirstName,
|
||||||
|
SecondName = model.SecondName,
|
||||||
|
Email = model.Email,
|
||||||
|
Birthday = model.Birthday,
|
||||||
|
Role = RoleConverter.ToView(model.Role),
|
||||||
|
};
|
||||||
|
|
||||||
|
public static UserBindingModel ToBinding(UserViewModel model) => new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
FirstName = model.FirstName,
|
||||||
|
SecondName = model.SecondName,
|
||||||
|
Email = model.Email,
|
||||||
|
Birthday = model.Birthday,
|
||||||
|
Role = RoleConverter.ToBinding(model.Role),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user