public async Task <ActionResult> Create([Bind(Include = "Id,Palestrante,MiniBioPalestrante,UrlSitePalestrante,TwitterPalestrante,UrlFotoPalestrante,Trilha,Titulo,Descricao,Data,HoraInicio,HoraTermino,CreatedAt,Deleted,UpdatedAt,Version")] AgendaEvento agendaEvento)
        {
            if (ModelState.IsValid)
            {
                db.AgendaEventoes.Add(agendaEvento);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(agendaEvento));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Color,User,UriImage,Complete,CreatedAt,Deleted,UpdatedAt,Version")] IoTActivity ioTActivity)
        {
            if (ModelState.IsValid)
            {
                db.IoTActivities.Add(ioTActivity);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(ioTActivity));
        }
Ejemplo n.º 3
0
        // GET api/GetNextColor
        /// <summary>
        /// Retorna a próxima cor a ser alterada no Stand
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage Get()
        {
            var           iotMessageQuery = db.IoTActivities.Where <IoTActivity>(iot => iot.Complete == false).OrderBy(iot => iot.CreatedAt);
            StringBuilder sb = new StringBuilder();



            if (iotMessageQuery.Count() > 0)
            {
                var iotMessage = iotMessageQuery.First();

                if (iotMessage != null)
                {
                    GetNextColorController.LastColor = iotMessage.Color;

                    iotMessage.Complete = true;
                    db.SaveChangesAsync();

                    sb.Append(String.Format("{0}\"{1}\":\"{2}\"{3}", "{", "color", iotMessage.Color.ToString().ToLower(), "}"));

                    iot4dx.Twitter.TwitterHelper.TwitteStatus(string.Format("User: {0} - Color: {1}", iotMessage.User, iotMessage.Color.ToString()));
                }
                else
                {
                    sb.Append(String.Format("{0}\"{1}\":\"{2}\"{3}", "{", "color", GetNextColorController.LastColor.ToString().ToLower(), "}"));

                    iot4dx.Twitter.TwitterHelper.TwitteStatus(string.Format("Last Color used - Color: {0}", iotMessage.Color.ToString()));
                }
            }
            else
            {
                sb.Append(String.Format("{0}\"{1}\":\"{2}\"{3}", "{", "color", GetNextColorController.LastColor.ToString().ToLower(), "}"));


                //Para teste utilizando cores Randômicas
                //var rand = new Random(DateTime.Now.Millisecond);
                //DataObjects.MicrosoftColors Color = (DataObjects.MicrosoftColors)rand.Next(1, 5);
                //sb.Append(String.Format("{0}\"{1}\":\"{2}\"{3}", "{", "color", Color.ToString().ToLower(), "}"));

                //Envio de twitte na conta
                // iot4dx.Twitter.TwitterHelper.TwitteStatus(string.Format("Modo de Teste IoT Color: {0}", Color.ToString()));
            }


            var resp = new HttpResponseMessage()
            {
                Content = new StringContent(sb.ToString())
            };

            return(resp);
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Mensagem,Agent,Microsoft,Android")] PushMessage pushMessage)
        {
            if (ModelState.IsValid)
            {
                db.PushMessages.Add(pushMessage);
                await db.SaveChangesAsync();

                //await PushHelper.SendPush(pushMessage);

                return(RedirectToAction("Index"));
            }

            return(View(pushMessage));
        }