Example #1
0
        public Queue AddItemToQueue(int userId, int itemId, int ownerId)
        {
            using (var context = GetContext())
            {
              //  var queue = context.Queue.FirstOrDefault(q => q.Requester.UserId == userId && q.ItemId == itemId);

               // if (queue == null)
               // {
                  var  queue = new Queue();

                    queue.ItemId = itemId;
                    queue.RequesterId = userId;
                    queue.OwnerId = ownerId;
                    queue.RequestDate = DateTime.Now;
                    queue.Status = QueueStatus.Reserved;
                    context.Queue.Add(queue);

                //}
                //else
                //{
                  //  context.Queue.Attach(queue);
                //}

                context.SaveChanges();

                return queue;
            }
        }
Example #2
0
        public void SaveQueue(Queue queue)
        {
            using (var context = GetContext())
            {

                context.Queue.Attach(queue);
                context.Entry(queue).State = System.Data.EntityState.Modified;
                context.SaveChanges();
            }
        }