예제 #1
0
        public HttpResponseMessage PostTerminalAlert(HttpRequestMessage alerts)
        {
            try
            {
                var p = alerts.Content.ReadAsStringAsync().Result;
                if (String.IsNullOrEmpty(p))
                {
                    List <KeyValuePair <string, string> > prueba = new List <KeyValuePair <string, string> >();
                    prueba.Add(new KeyValuePair <string, string>("TerminalId", "TR024019"));
                    prueba.Add(new KeyValuePair <string, string>("CashAvailable", "345"));
                    prueba.Add(new KeyValuePair <string, string>("AlarmChestdooropen", "True"));
                    prueba.Add(new KeyValuePair <string, string>("AlarmTopdooropen", "True"));
                    prueba.Add(new KeyValuePair <string, string>("AlarmSupervisoractive", "True"));
                    prueba.Add(new KeyValuePair <string, string>("Receiptprinterpaperstatus", "Low"));
                    prueba.Add(new KeyValuePair <string, string>("ReceiptPrinterRibbonStatus", "Out"));
                    prueba.Add(new KeyValuePair <string, string>("JournalPrinterPaperStatus", "Low"));
                    _repository.SaveAlerts(prueba);
                }
                else
                {
                    List <KeyValuePair <string, string> > list = JsonConvert.DeserializeObject <List <KeyValuePair <string, string> > >(p);
                    _repository.SaveAlerts(list);
                }

                HttpResponseMessage respo = new HttpResponseMessage(HttpStatusCode.OK);
                return(respo);
            }
            catch (Exception ex)
            {
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                WebMail.EnableSsl  = true;
                WebMail.From       = "*****@*****.**";
                WebMail.SmtpPort   = 25;
                WebMail.UserName   = "******";
                WebMail.SmtpServer = "smtp.live.com";
                WebMail.Password   = "******";
                WebMail.SmtpUseDefaultCredentials = true;

                WebMail.Send("*****@*****.**", "Error en el Api ", ex.Message + " " + ex.InnerException.Message);

                return(response);

                throw;
            }
        }
예제 #2
0
        // POST: api/TerminalAlerts
        //[ResponseType(typeof(TerminalAlert))]
        public void PostTerminalAlert(HttpRequestMessage alerts)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            List <KeyValuePair <string, string> > prueba = new List <KeyValuePair <string, string> >();

            prueba.Add(new KeyValuePair <string, string>("TerminalId", "TR024019"));
            prueba.Add(new KeyValuePair <string, string>("CashAvailable", "345"));


            //var p = alerts.Content.ReadAsStringAsync().Result;
            //List<KeyValuePair<string, string>> list = JsonConvert.DeserializeObject<List<KeyValuePair<string, string>>>(p);

            _repository.SaveAlerts(prueba);
            //terminalAlert.TerminalId = list.FirstOrDefault(c => c.Key == "TerminalId").Value;
            //terminalAlert.CashAvailable = Convert.ToInt32(list.FirstOrDefault(c => c.Key == "CashAvailable").Value);

            //db.SaveChanges();
        }