Example #1
0
        private List <Models.InputOwners> GetOrderedAddonsInQueue(int?subscriberId, int?clientId, Props.QueuePosition queuePosition)
        {
            List <Models.InputOwners> inputOwners = new List <Models.InputOwners>();

            using (var db = new CoreContext())
            {
                var owners = db.InputOwners.Where(x => x.QueuePosition == queuePosition && x.HasOwnership == false);

                if (subscriberId != null)
                {
                    owners = owners.Where(y => y.Users.SubscriberId == subscriberId);
                }
                if (clientId != null)
                {
                    owners = owners.Where(y => y.UserId == clientId);
                }

                owners = owners = owners.OrderBy(x => x.Created);

                return(owners.ToList());
            }
        }
Example #2
0
        public void RequestInput(IComponent Component, Core.UserManager.Models.Users user, int?inputWaitDuration = null, Props.ReleaseRequestAction releaseRequestAction = Props.ReleaseRequestAction.Ask, Props.QueuePosition queuePosition = Props.QueuePosition.Last)
        {
            TimeSpan?ts = null;

            if (inputWaitDuration != null)
            {
                ts = TimeSpan.FromSeconds(Convert.ToInt32(inputWaitDuration));
            }

            Models.InputOwners inputOwner = new Models.InputOwners()
            {
                Name = Component.Name,
                ReleaseRequestAction = releaseRequestAction,
                QueuePosition        = queuePosition,
                InputWaitDuration    = ts,
                UserId = user.UserId,
                Users  = user,
            };

            using (var db = new CoreContext())
            {
                db.InputOwners.Add(inputOwner);
            }

            UpdateInputQueue(user.SubscriberId);
        }