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.

ArticlesBusiness.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Linq;
  2. using Luticate2.Utils.Business;
  3. using Luticate2.Utils.Dbo.Basic;
  4. using Luticate2.Utils.Dbo.PaginatedRequest;
  5. using Luticate2.Utils.Dbo.Result;
  6. using Luticate2.Utils.Interfaces;
  7. using WebApiWebSem.DataAccess;
  8. using WebApiWebSem.Dbo.Articles;
  9. using WebApiWebSem.Dbo.ArticlesFields;
  10. namespace WebApiWebSem.Business
  11. {
  12. public class ArticlesBusiness : LuCrudBusiness<ArticlesDataAccess, ArticlesAddDbo, ArticlesDbo, ArticlesEditDbo, string>
  13. {
  14. private readonly DbPediaDataAccess _dbPediaDataAccess;
  15. public ArticlesBusiness(ArticlesDataAccess dataAccess, ILuNotificationsBusiness notificationsBusiness, DbPediaDataAccess dbPediaDataAccess) : base(dataAccess, notificationsBusiness)
  16. {
  17. _dbPediaDataAccess = dbPediaDataAccess;
  18. EntityType = "articles";
  19. }
  20. public override LuResult<LuPaginatedDbo<ArticlesDbo>> GetMultiple(LuPaginatedRequestDbo request)
  21. {
  22. var result = _dbPediaDataAccess.GetMultiple(request);
  23. if (result.Status == LuStatus.BackendError)
  24. {
  25. return base.GetMultiple(request);
  26. }
  27. DataAccess.AddDbo(result.Data.Data.Select(dbo => new ArticlesAddDbo
  28. {
  29. Fields = dbo.Fields.Select(fieldsDbo => new ArticlesFieldsAddDbo
  30. {
  31. Property = fieldsDbo.Property,
  32. Type = fieldsDbo.Type,
  33. Value = fieldsDbo.Value
  34. }).ToList(),
  35. Id = dbo.Id,
  36. PictureCaption = dbo.PictureCaption,
  37. PictureUrl = dbo.PictureUrl,
  38. Text = dbo.Text,
  39. Type = dbo.Type
  40. }));
  41. return result;
  42. }
  43. }
  44. }