using Quadarax.Application.QLiberace.Common.Repositories; using Quadarax.Application.QLiberace.Common.Domain; using Quadarax.Application.QLiberace.Processor.Entities; using Quadarax.Foundation.Core.Data; using Quadarax.Foundation.Core.Data.Domain; using Quadarax.Foundation.Core.Data.Interface.Domain; namespace Quadarax.Application.QLiberace.Processor.Repositories { public class RepoQueueData : QlbrcRepository { public RepoQueueData(IUnitOfWork unitOfWork, QlbrcContext operationContext) : base(unitOfWork, operationContext) { } public void New(int parentId) { var data = New(); data.ParentId = parentId; } public IQueryable GetQueueData(long headDataId) { return Query(Paging.NoPaging()).Where(x => x.ParentId == headDataId || x.Id == headDataId).OrderBy(x => x.SequenceNo); } public void UpdateQueueData(long headDataId, string code, string? value) { var item = Query(Paging.NoPaging()).FirstOrDefault(x => (x.ParentId == headDataId || x.Id == headDataId) && x.Code == code); if (item == null) throw new InvalidOperationException( $"No data found in QueueData for headDataId = {headDataId} and code = '{code}'!"); if (item.IsInput) throw new InvalidOperationException( $"QueueData for headDataId = {headDataId} and code = '{code}' is only for input, cannot modify value!"); item.Value = value; } } }