Ejemplo n.º 1
0
        public IActionResult GetAllAdminIdeations(int id, [FromServices] IIoTManager ioTManager)
        {
            List <Ideation> ideations = _ideationManager.GetAllAdminIdeations(id).ToList();

            List <IdeationViewModel> ideationViewModels = new List <IdeationViewModel>();


            foreach (var ideation in ideations)
            {
                bool hasReplies = ideation.Replies.Any();
                if (!hasReplies)
                {
                    continue;
                }
                IoTDTO iotLink = null;
                if (hasReplies)
                {
                    IotLink link = null;
                    link = ioTManager.GetIoTLinkByIdeationReply(ideation.Replies[0]);
                    if (link != null)
                    {
                        iotLink = new IoTDTO()
                        {
                            IotLinkId  = link.IotLinkId,
                            IsForm     = false,
                            IdeationId = ideation.Replies[0].IdeationReplyId,
                            Location   = new LocationDTO()
                            {
                                Longitude = link.Location.Longitude,
                                Latitude  = link.Location.Latitude,
                                ZoomLevel = link.Location.ZoomLevel
                            }
                        };
                    }
                }
                IdeationViewModel vm = new IdeationViewModel()
                {
                    CentralQuestion = ideation.CentralQuestion,
                    Description     = ideation.Description,
                    IdeationId      = ideation.IdeationId,
                    HasReplies      = hasReplies,
                    IotLink         = iotLink
                };
                ideationViewModels.Add(vm);
            }

            return(Ok(ideationViewModels));
        }