RepoQueueData.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Quadarax.Application.QLiberace.Common.Repositories;
  2. using Quadarax.Application.QLiberace.Common.Domain;
  3. using Quadarax.Application.QLiberace.Processor.Entities;
  4. using Quadarax.Foundation.Core.Data;
  5. using Quadarax.Foundation.Core.Data.Domain;
  6. using Quadarax.Foundation.Core.Data.Interface.Domain;
  7. namespace Quadarax.Application.QLiberace.Processor.Repositories
  8. {
  9. public class RepoQueueData : QlbrcRepository<QueueData>
  10. {
  11. public RepoQueueData(IUnitOfWork<IDataDomain> unitOfWork, QlbrcContext operationContext) : base(unitOfWork, operationContext)
  12. {
  13. }
  14. public void New(int parentId)
  15. {
  16. var data = New();
  17. data.ParentId = parentId;
  18. }
  19. public IQueryable<QueueData> GetQueueData(long headDataId)
  20. {
  21. return Query(Paging.NoPaging()).Where(x => x.ParentId == headDataId || x.Id == headDataId).OrderBy(x => x.SequenceNo);
  22. }
  23. public void UpdateQueueData(long headDataId, string code, string? value)
  24. {
  25. var item = Query(Paging.NoPaging()).FirstOrDefault(x => (x.ParentId == headDataId || x.Id == headDataId) && x.Code == code);
  26. if (item == null)
  27. throw new InvalidOperationException(
  28. $"No data found in QueueData for headDataId = {headDataId} and code = '{code}'!");
  29. if (item.IsInput)
  30. throw new InvalidOperationException(
  31. $"QueueData for headDataId = {headDataId} and code = '{code}' is only for input, cannot modify value!");
  32. item.Value = value;
  33. }
  34. }
  35. }