You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModelsDbo.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Linq;
  2. using Luticate2.Utils.Utils;
  3. using WebApiWebSem.DataAccess.Models;
  4. using WebApiWebSem.Dbo.Articles;
  5. using WebApiWebSem.Dbo.ArticlesFields;
  6. namespace WebApiWebSem.DataAccess
  7. {
  8. public static class ModelsDbo
  9. {
  10. public static ArticlesFieldsDbo ToDbo(this articles_fields model)
  11. {
  12. if (model == null)
  13. {
  14. return null;
  15. }
  16. return new ArticlesFieldsDbo
  17. {
  18. Property = model.property,
  19. Type = model.type,
  20. Value = model.value
  21. };
  22. }
  23. public static ArticlesDbo ToDbo(this articles model)
  24. {
  25. if (model == null)
  26. {
  27. return null;
  28. }
  29. return new ArticlesDbo
  30. {
  31. CreatedAt = model.created_at.ToDbo(),
  32. Fields = model.articles_fields_fk.OrderBy(fields => fields.property).Select(fields => fields.ToDbo()).ToList(),
  33. Id = model.id,
  34. PictureCaption = model.picture_caption,
  35. PictureUrl = model.picture_url,
  36. Text = model.text,
  37. Type = model.type,
  38. UpdatedAt = model.updated_at.ToDbo()
  39. };
  40. }
  41. }
  42. }