public IActionResult GetQueueItemsByHelpdeskID([FromRoute] int id)
        {
            try
            {
                var facade   = new QueueFacade();
                var response = facade.GetQueueItemsByHelpdeskID(id);

                switch (response.Status)
                {
                case HttpStatusCode.OK:
                    return(Ok(response));

                case HttpStatusCode.BadRequest:
                    return(BadRequest(BuildBadRequestMessage(response)));

                case HttpStatusCode.NotFound:
                    return(NotFound());

                case HttpStatusCode.InternalServerError:
                    return(StatusCode(StatusCodes.Status500InternalServerError));
                }
                s_logger.Fatal("This code should be unreachable, unknown result has occured.");
            }
            catch (Exception ex)
            {
                s_logger.Error(ex, "Unable to get queue items.");
            }
            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
        public void GetQueueItemsByHelpdeskIDNoHelpdesk()
        {
            QueueFacade facade = new QueueFacade();

            GetQueueItemsByHelpdeskIDResponse testResponse = facade.GetQueueItemsByHelpdeskID(-1);

            Assert.AreEqual(HttpStatusCode.NotFound, testResponse.Status);
        }
        public void GetQueueItemsByHelpdeskIDNoItems()
        {
            Helpdesksettings helpdesk = new Helpdesksettings()
            {
                HasQueue   = true,
                HasCheckIn = false,
                IsDeleted  = false,
                Name       = AlphaNumericStringGenerator.GetString(10),
            };

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                context.Helpdesksettings.Add(helpdesk);
                context.SaveChanges();
            }

            QueueFacade facade = new QueueFacade();

            GetQueueItemsByHelpdeskIDResponse testResponse = facade.GetQueueItemsByHelpdeskID(helpdesk.HelpdeskId);

            Assert.AreEqual(HttpStatusCode.NotFound, testResponse.Status);
        }
        public void GetQueueItemsByHelpdeskID()
        {
            Helpdesksettings helpdesk = new Helpdesksettings()
            {
                HasQueue   = true,
                HasCheckIn = false,
                IsDeleted  = false,
                Name       = AlphaNumericStringGenerator.GetString(10),
            };

            Unit unit = new Unit()
            {
                Code      = AlphaNumericStringGenerator.GetString(8),
                IsDeleted = false,
                Name      = AlphaNumericStringGenerator.GetString(10),
            };

            Topic topic = new Topic()
            {
                IsDeleted = false,
                Name      = AlphaNumericStringGenerator.GetString(10),
            };

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                context.Helpdesksettings.Add(helpdesk);
                context.Unit.Add(unit);
                context.SaveChanges();

                Helpdeskunit helpdeskunit = new Helpdeskunit()
                {
                    HelpdeskId = helpdesk.HelpdeskId,
                    UnitId     = unit.UnitId
                };

                context.Helpdeskunit.Add(helpdeskunit);
                context.SaveChanges();

                topic.UnitId = unit.UnitId;
                context.Topic.Add(topic);
                context.SaveChanges();
            }

            AddToQueueRequest request = new AddToQueueRequest()
            {
                Nickname    = AlphaNumericStringGenerator.GetString(10),
                SID         = AlphaNumericStringGenerator.GetStudentIDString(),
                TopicID     = topic.TopicId,
                Description = "GetQueueItemsByHelpdeskID Test"
            };

            QueueFacade facade = new QueueFacade();

            AddToQueueResponse response = facade.AddToQueue(request);

            Assert.AreEqual(HttpStatusCode.OK, response.Status);

            GetQueueItemsByHelpdeskIDResponse testResponse = facade.GetQueueItemsByHelpdeskID(helpdesk.HelpdeskId);

            Assert.AreEqual(HttpStatusCode.OK, testResponse.Status);
            var itemIds = testResponse.QueueItems.Select(i => i.ItemId).ToList();

            Assert.IsTrue(itemIds.Contains(response.ItemId));
        }