123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Linq;
- using Luticate2.Utils.Dbo.OrderBy;
- using Luticate2.Utils.Utils;
- using WebApiWebSem.DataAccess.Models;
- using WebApiWebSem.Dbo.Articles;
- using WebApiWebSem.Dbo.ArticlesFields;
-
- namespace WebApiWebSem.DataAccess
- {
- public static class ModelsDbo
- {
- public static ArticlesFieldsDbo ToDbo(this articles_fields model)
- {
- if (model == null)
- {
- return null;
- }
- return new ArticlesFieldsDbo
- {
- Property = model.property,
- Type = model.type,
- Value = model.value
- };
- }
-
- public static ArticlesDbo ToDbo(this articles model)
- {
- if (model == null)
- {
- return null;
- }
- return new ArticlesDbo
- {
- CreatedAt = model.created_at.ToDbo(),
- Fields = model.articles_fields_fk.OrderBy(fields => fields.property).Select(fields => fields.ToDbo()).ToList(),
- Id = model.id,
- PictureCaption = model.picture_caption,
- PictureUrl = model.picture_url,
- Text = model.text,
- Type = model.type,
- UpdatedAt = model.updated_at.ToDbo()
- };
- }
-
- public static string ToDbPediaModel(this LuOrderByDbo orderByDbo)
- {
- return string.Join(" ", orderByDbo.Fields.Select(dbo =>
- {
- var order = dbo.Asc ? "ASC" : "DESC";
- return $"{order}(?{dbo.Name})";
- }));
- }
- }
- }
|