コード例 #1
0
        /*user join the queue*/
        public static void Insert(string nickname, int userId, int queueId)
        {
            using (var context = new eQueueContext())
            {
                UserAccess access = new UserAccess {
                    Nickname = nickname, AccessTypeName = AccessType.Default
                };
                User      user  = context.Users.Find(userId);
                QueueInfo queue = context.Queues.Find(queueId);

                user.UserAccesses.Add(access);
                queue.UserAccesses.Add(access);
                access.User      = user;
                access.QueueInfo = queue;

                context.UserAccesses.Add(access);
                context.SaveChanges();
            }
        }
コード例 #2
0
ファイル: QueueManager.cs プロジェクト: lazy-penguin/eQueue
        /*create new QueueInfo and UserAcces with info about queue's owner*/
        public static QueueInfo Insert(string queueName, string link, DateTime?timer, int ownerId)
        {
            using (var context = new eQueueContext())
            {
                var queue = new QueueInfo {
                    Name = queueName, Link = link, Timer = timer
                };
                var owner  = context.Users.Find(ownerId);
                var access = new UserAccess
                {
                    Nickname       = owner.Login,
                    AccessTypeName = AccessType.Owner,
                    User           = owner,
                    QueueInfo      = queue
                };

                context.Queues.Add(queue);
                context.UserAccesses.Add(access);
                context.SaveChanges();

                return(queue);
            }
        }