using System.Linq; 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() }; } } }