Пример #1
0
        public ActionResult Put(int id, [FromBody] AlertDTO alert)
        {
            var dao = new AlertDAO();
            int resultNonQuery;

            try
            {
                resultNonQuery = dao.editAlert(id, alert);
            }
            catch (Exception e)
            {
                return(this.BadRequest($"Operacion de Modificar fallo: {e.Message}"));

                throw;
            }
            return(this.GetQueryResponse(resultNonQuery, "Modificar"));

            /*
             * var connection = new SqlConnection("data source=104.217.253.86;initial catalog=tracking;user id=alumno;password=12345678");
             * connection.Open();
             *
             * var sql =   @$"UPDATE alert
             *          set name = '{alert.Name}', notifywhenarriving = '{alert.Notifywhenarriving}',
             *          notifywhenleaving = '{alert.Notifywhenleaving}',
             *          enterpriseid = {alert.enterpriseid}, active = '{alert.Active}'
             *          WHERE id = {id}";
             *
             * var command = new SqlCommand(sql, connection);
             * string response = GetQueryResponse(command, "Modificar");
             *
             * connection.Close();
             * return Ok(response);
             */
        }
Пример #2
0
    static void Main(string[] args)
    {
        IAlertDAO    alertDao = new AlertDAO();
        AlertService alert    = new AlertService(alertDao);
        Guid         id       = alert.RaiseAlert();

        Console.WriteLine(alert.GetAlertTime(id));
        Console.ReadKey();
    }
Пример #3
0
        public void TestTwoAlertsDiffHash()
        {
            AlertDAO strg1 = new AlertDAO();
            AlertDAO strg2 = new AlertDAO();

            strg1.AddAlert(new DateTime());
            strg2.Add(strg1.GetKeyAtPos(0), strg1.GetValAtPos(0).AddMilliseconds(1));

            Assert.AreEqual(false, strg1.GetHashCode() == strg2.GetHashCode(), $"{ strg1.GetHashCode()} ,{strg2.GetHashCode()}");
        }
        public void AlertService_GetAlertTime()
        {
            // Arrange.
            IAlertDAO    alertDAO     = new AlertDAO();
            AlertService alertService = new AlertService(alertDAO);

            // Act.
            alertService.RaiseAlert();
            alertService.GetAlertTime(Guid.NewGuid());

            // Assert.
        }
Пример #5
0
        public void TestTwoAlertsAreNotEqual()
        {
            AlertDAO strg1 = new AlertDAO();
            AlertDAO strg2 = new AlertDAO();

            strg1.AddAlert(new DateTime());
            strg2.Add(strg1.GetKeyAtPos(0), strg1.GetValAtPos(0).AddMilliseconds(1));



            Assert.AreEqual(false, strg1.Equals(strg2));
        }
Пример #6
0
        public void TestTwoAlertsAreEqual()
        {
            AlertDAO strg1 = new AlertDAO();
            AlertDAO strg2 = new AlertDAO();

            strg1.AddAlert(new DateTime());
            strg1.AddAlert(new DateTime());

            strg2.Add(strg1.GetKeyAtPos(1), strg1.GetValAtPos(1));
            strg2.Add(strg1.GetKeyAtPos(0), strg1.GetValAtPos(0));

            Assert.AreEqual(true, strg1.Equals(strg2));
        }
Пример #7
0
        public void TestTwoAlertsSameHash()
        {
            AlertDAO strg1 = new AlertDAO();
            AlertDAO strg2 = new AlertDAO();

            strg1.AddAlert(new DateTime());
            strg1.AddAlert(new DateTime());


            strg2.Add(strg1.GetKeyAtPos(1), strg1.GetValAtPos(1));
            strg2.Add(strg1.GetKeyAtPos(0), strg1.GetValAtPos(0));


            Assert.AreEqual(true, strg1.GetHashCode() == strg2.GetHashCode(), $"{ strg1.GetHashCode()} ,{strg2.GetHashCode()}");
        }
Пример #8
0
        public ActionResult Delete(int id)
        {
            var dao = new AlertDAO();
            int resultNonQuery;

            try
            {
                resultNonQuery = dao.removeAlert(id);
            }
            catch (Exception e)
            {
                return(this.BadRequest($"Operacion de eliminar fallo: {e.Message}"));

                throw;
            }
            return(this.GetQueryResponse(resultNonQuery, "Eliminar"));
        }
Пример #9
0
        public ActionResult Post([FromBody] AlertDTO alert)
        {
            var dao = new AlertDAO();
            int resultNonQuery;

            try
            {
                resultNonQuery = dao.addAlert(alert);
            }
            catch (Exception e)
            {
                return(this.BadRequest($"Operacion de Modificar fallo: {e.Message}"));

                throw;
            }
            return(this.GetQueryResponse(resultNonQuery, "Agregar"));
        }
Пример #10
0
        public IEnumerable <AlertDTO> Get()
        {
            var dao = new AlertDAO();

            return(dao.getAllAlert());
        }
Пример #11
0
        public IEnumerable <AlertDTO> Get(int top)
        {
            var dao = new AlertDAO();

            return(dao.getTopAlert(top));
        }
Пример #12
0
 public AlertService(IAlertDAO alertDao)
 {
     this.storage = (AlertDAO)alertDao;
 }