public static Post DtoToPost(this PostDto p)
{
return new Post { Id = p.Id, Categories = p.Categories.DtoListToCategoryList(),
Content = p.Content, CreatedAt = p.CreatedAt, DeletedAt = p.DeletedAt, Title = p.Title,
UpdatedAt = p.UpdatedAt, UserId = p.UserId, User = p.User.DtoToUser() };
}
public static List<Category> DtoListToCategoryList(this List<CategoryDto> p)
{
List<Category> dtos = new List<Category>();
foreach (var item in p)
{
dtos.Add(item.DtoToCategory());
}
return dtos;
}
public static Category DtoToCategory(this CategoryDto c)
{
return new Category { Description = c.Description, Name = c.Name, Id = c.Id, Slug = c.Slug };
}
public static User DtoToUser(this UserDto u)
{
return new User { City = u.City, Email = u.Email, Id = u.Id, Name = u.Name, Password = u.Password, Phone = u.Phone };
}