public int Insert(ActedAlarm actedAlarm) { string cmd = @"INSERT INTO Alarms_Acted(Id_Alarm,Id_Status,InputDate,OutputDate) VALUES(@Id_Alarm,@Id_Status,@InputDate,@OutputDate) SELECT SCOPE_IDENTITY()"; ApiConn.DAO.AddParameter("@Id_Alarm", actedAlarm.Id_Alarm); ApiConn.DAO.AddParameter("@Id_Status", actedAlarm.Id_Status); if (actedAlarm.InputDate > DateTime.MinValue) { ApiConn.DAO.AddParameter("@InputDate", actedAlarm.InputDate); } else { ApiConn.DAO.AddParameter("@InputDate", DBNull.Value); } if (actedAlarm.OutputDate > DateTime.MinValue) { ApiConn.DAO.AddParameter("@OutputDate", actedAlarm.OutputDate); } else { ApiConn.DAO.AddParameter("@OutputDate", DBNull.Value); } return(ApiConn.DAO.ExecuteScalar(cmd)); }
public void Delete(ActedAlarm actedAlarm) { string cmd = @"DELETE FROM Alarms_Acted WHERE Id = @Id"; ApiConn.DAO.AddParameter("@Id", actedAlarm.Id); ApiConn.DAO.ExecuteNonQuery(cmd); }
public bool ValidateInsert(ActedAlarm actedAlarm) { if (actedAlarm.Id != 0) { this._Notifications.Add(new Notification { field = "Id", value = actedAlarm.Id, message = "Id can't be different than 0." }); } if (actedAlarm.Id_Alarm == 0) { this._Notifications.Add(new Notification { field = "Id_Alarm", value = actedAlarm.Id_Alarm, message = "Choose an Alarm to insert this ActedAlarmIL." }); } if (actedAlarm.Id_Status == 0) { this._Notifications.Add(new Notification { field = "Id_Status", value = actedAlarm.Id_Status, message = "ActedAlarmIL can't be inserted without an Status." }); } if (actedAlarm.InputDate == DateTime.MinValue) { this._Notifications.Add(new Notification { field = "InputDate", value = actedAlarm.Id, message = "InputDate should be informed" }); } if (actedAlarm.RegisterDate != DateTime.MinValue) { this._Notifications.Add(new Notification { field = "RegisterDate", value = actedAlarm.RegisterDate, message = "Register Date should be inserted by DataBase." }); } return(_Notifications.Count > 0 ? false : true); }
public bool ValidateSelect(ActedAlarm actedAlarm) { if (actedAlarm.Id == 0) { this._Notifications.Add(new Notification { field = "Id", value = actedAlarm.Id, message = "Id can't be 0." }); } return(_Notifications.Count > 0 ? false : true); }
public void Delete(ActedAlarm actedAlarm) { IntegityLayer.ValidateDelete(actedAlarm); if (IntegityLayer.Notifications.Count > 0) { this.Notifiable.Notifications = IntegityLayer.Notifications; this.Notifiable.StatusCode = (int)HttpStatusCode.BadRequest; return; } this.DAL.Delete(actedAlarm); this.Notifiable.StatusCode = (int)HttpStatusCode.OK; }
public void Update(ActedAlarm actedAlarm) { string cmd = @"UPDATE Alarms_Acted SET Id_Alarm = @Id_Classification, Id_Status = @Id_Equipment, InputDate = @Description, OutputDate = @OutputDate WHERE Id = @Id"; ApiConn.DAO.AddParameter("@Id_Alarm", actedAlarm.Id_Alarm); ApiConn.DAO.AddParameter("@Id_Status", actedAlarm.Id_Status); ApiConn.DAO.AddParameter("@InputDate", actedAlarm.InputDate); ApiConn.DAO.AddParameter("@OutputDate", actedAlarm.OutputDate); ApiConn.DAO.ExecuteNonQuery(cmd); }
public int Insert(ActedAlarm actedAlarmIL) { IntegityLayer.ValidateInsert(actedAlarmIL); if (IntegityLayer.Notifications.Count > 0) { this.Notifiable.Notifications = IntegityLayer.Notifications; this.Notifiable.StatusCode = (int)HttpStatusCode.BadRequest; return(0); } int id = this.DAL.Insert(actedAlarmIL); this.Notifiable.StatusCode = (int)HttpStatusCode.Created; return(id); }