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); */ }
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(); }
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. }
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)); }
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)); }
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()}"); }
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")); }
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")); }
public IEnumerable <AlertDTO> Get() { var dao = new AlertDAO(); return(dao.getAllAlert()); }
public IEnumerable <AlertDTO> Get(int top) { var dao = new AlertDAO(); return(dao.getTopAlert(top)); }
public AlertService(IAlertDAO alertDao) { this.storage = (AlertDAO)alertDao; }