Exemplo n.º 1
0
        public IActionResult CreateLink(IoTDTO iot, [FromServices] IFormManager formManager, [FromServices] IIdeationManager ideationManager, [FromServices] IIoTManager ioTManager, [FromServices]  UnitOfWorkManager unitOfWorkManager)
        {
            IotLink  link     = null;
            Location location = new Location()
            {
                Longitude = iot.Location.Longitude,
                Latitude  = iot.Location.Latitude,
                ZoomLevel = iot.Location.ZoomLevel
            };


            if (iot.IsForm)
            {
                Form form = formManager.GetForm(iot.FormId);
                if (form == null)
                {
                    return(NotFound());
                }
                link = ioTManager.CreateIotLink(form, null, form.Project, location);
            }

            else
            {
                Ideation      ideation = ideationManager.GetIdeationWithReplies(iot.IdeationId);
                IdeationReply reply    = ideationManager.GetIdeationReply(ideation.Replies[0].IdeationReplyId);
                if (reply == null)
                {
                    return(NotFound());
                }
                link = ioTManager.CreateIotLink(null, reply, ideation.Project, location);
            }
            unitOfWorkManager.Save();

            return(Created("", new { id = link.IotLinkId }));
        }
Exemplo n.º 2
0
        public IActionResult EditLink(IoTDTO iot, [FromServices] IFormManager formManager, [FromServices] IIdeationManager ideationManager, [FromServices] IIoTManager ioTManager, [FromServices]  UnitOfWorkManager unitOfWorkManager)
        {
            IotLink link = ioTManager.GetIoTLink(iot.IotLinkId);

            Location location = new Location()
            {
                Longitude = iot.Location.Longitude,
                Latitude  = iot.Location.Latitude,
                ZoomLevel = iot.Location.ZoomLevel
            };

            link.Location = location;

            ioTManager.UpdateIotLink(link);
            unitOfWorkManager.Save();

            return(Ok());
        }