Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            AdminAlert adminAlert = obj as AdminAlert;

            return(adminAlert.Id.Equals(Id));
        }
Ejemplo n.º 2
0
        public bool AddAdminAlert(AdminAlert adminAlert)
        {
            MySqlConnection conn = null;

            try
            {
                conn = ConnectionManager.GetConnection();

                MySqlCommand cmd = new MySqlCommand(INSERT_ADMIN_ALERT, conn);

                cmd.Parameters.AddWithValue("@id", adminAlert.Id.ToString());
                cmd.Parameters.AddWithValue("@email", adminAlert.Email);
                cmd.Parameters.AddWithValue("@creation_date", adminAlert.CreationDate.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                cmd.Parameters.AddWithValue("@lat", adminAlert.Lat);
                cmd.Parameters.AddWithValue("@longi", adminAlert.Longi);
                cmd.Parameters.AddWithValue("@alert", adminAlert.Alert);
                cmd.Parameters.AddWithValue("@parent_id", adminAlert.ParentId.ToString());
                cmd.Parameters.AddWithValue("@child_id", adminAlert.ChildId.ToString());

                int rowsAffected = cmd.ExecuteNonQuery();
                if (rowsAffected > 1)
                {
                    throw new Exception("repeated id");
                }

                return(true);
            }
            catch (MySqlException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message.ToString());
            }
            finally
            {
                if (conn != null && conn.State != System.Data.ConnectionState.Closed)
                {
                    conn.Close();
                }
            }
            return(false);
        }