Esempio n. 1
0
        public List <Report> GetAll()
        {
            List <Report> reports = new List <Report>();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand    sqlCommand    = new SqlCommand(@"SELECT Report.Id,Report.SiteTitle,Ban.[Name],Report.[DateTime] FROM Ban INNER JOIN Report ON (Ban.Id=Report.BanID)", connection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    reports.Add(new Report()
                    {
                        Id        = (int)sqlDataReader["Id"],
                        SiteTitle = sqlDataReader["SiteTitle"].ToString(),
                        DateTime  = (DateTime)sqlDataReader["DateTime"],
                        Ban       = new Ban()
                        {
                            Name = sqlDataReader["Name"].ToString()
                        }
                    });
                }

                connection.Close();
                return(reports);
            }
        }
Esempio n. 2
0
 public bool Delete(int id)
 {
     using (var connection = SqlConnectionContext.Connection())
     {
         SqlCommand sqlCommand = new SqlCommand(@"DELETE FROM [Report] WHERE Id= @reportId", connection);
         sqlCommand.Parameters.AddWithValue("@reportId", id);
         int result = sqlCommand.ExecuteNonQuery();
         connection.Close();
         return(result > 0);
     }
 }
Esempio n. 3
0
        public bool Delete(Mail mail)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"DELETE FROM [Mail] WHERE Id = @id", connection);
                sqlCommand.Parameters.AddWithValue("@id", mail.Id);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 4
0
        public bool Add(Ban ban)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO [Ban] VALUES(@name)", connection);
                sqlCommand.Parameters.AddWithValue("@name", ban.Name);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 5
0
        public bool Add(Mail mail)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO [Mail] VALUES(@adress)", connection);
                sqlCommand.Parameters.AddWithValue("@adress", mail.Adress);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 6
0
        public bool Add(User user)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO [User] VALUES(@name,@password)", connection);
                sqlCommand.Parameters.AddWithValue("@name", user.Name);
                sqlCommand.Parameters.AddWithValue("@password", user.Password);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 7
0
 public bool Add(Report report)
 {
     using (var connection = SqlConnectionContext.Connection())
     {
         SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO [Report] VALUES (@siteTitle,@dateTime,@banId)", connection);
         sqlCommand.Parameters.AddWithValue("@siteTitle", report.SiteTitle);
         sqlCommand.Parameters.AddWithValue("@dateTime", report.DateTime);
         sqlCommand.Parameters.AddWithValue("@banId", report.BanID);
         int result = sqlCommand.ExecuteNonQuery();
         connection.Close();
         return(result > 0);
     }
 }
Esempio n. 8
0
 public bool Update(Report report)
 {
     using (var connection = SqlConnectionContext.Connection())
     {
         SqlCommand sqlCommand = new SqlCommand(@"UPDATE [Report] SET SiteTitle=@siteTitle,DateTime=@dateTime WHERE Id= @reportId", connection);
         sqlCommand.Parameters.AddWithValue("@siteTitle", report.SiteTitle);
         sqlCommand.Parameters.AddWithValue("@dateTime", report.DateTime);
         sqlCommand.Parameters.AddWithValue("@reportId", report.Id);
         int result = sqlCommand.ExecuteNonQuery();
         connection.Close();
         return(result > 0);
     }
 }
Esempio n. 9
0
        public bool Update(Ban ban)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"UPDATE [Ban] SET Name=@name WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@name", ban.Name);
                sqlCommand.Parameters.AddWithValue("@id", ban.Id);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 10
0
        public bool Update(Mail mail)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"UPDATE [Mail] SET Adress=@adress WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@adress", mail.Adress);
                sqlCommand.Parameters.AddWithValue("@id", mail.Id);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 11
0
        public bool Update(User user)
        {
            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"UPDATE [User] SET Name=@name,Password=@password WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@name", user.Name);
                sqlCommand.Parameters.AddWithValue("@password", user.Password);
                sqlCommand.Parameters.AddWithValue("@id", user.Id);

                int result = sqlCommand.ExecuteNonQuery();
                connection.Close();
                return(result > 0);
            }
        }
Esempio n. 12
0
        public Mail Get(int id)
        {
            Mail mail = new Mail();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"SELECT * FROM [Mail] WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@id", id);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.Read())
                {
                    mail.Id     = (int)sqlDataReader["Id"];
                    mail.Adress = sqlDataReader.ToString();
                }

                connection.Close();
                return(mail);
            }
        }
Esempio n. 13
0
        public Ban Get(int id)
        {
            Ban ban = new Ban();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"SELECT * FROM [Ban] WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@id", id);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.Read())
                {
                    ban.Id   = (int)sqlDataReader[0];
                    ban.Name = sqlDataReader.ToString();
                }

                connection.Close();
                return(ban);
            }
        }
Esempio n. 14
0
        public List <Mail> GetAll()
        {
            List <Mail> mails = new List <Mail>();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand    sqlCommand    = new SqlCommand(@"SELECT * FROM Mail", connection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    mails.Add(new Mail()
                    {
                        Id     = (int)sqlDataReader["Id"],
                        Adress = sqlDataReader["Adress"].ToString()
                    });
                }
                connection.Close();
                return(mails);
            }
        }
Esempio n. 15
0
        public User Get(int id)
        {
            User user = new User();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"SELECT * FROM [User] WHERE Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@id", id);

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.Read())
                {
                    user.Id       = sqlDataReader.GetInt32(0);
                    user.Name     = sqlDataReader.GetString(1);
                    user.Password = sqlDataReader.GetString(2);
                }
                connection.Close();
                return(user);
            }
        }
Esempio n. 16
0
        public List <Ban> GetAll()
        {
            List <Ban> bans = new List <Ban>();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand    sqlCommand    = new SqlCommand(@"SELECT * FROM Ban", connection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    bans.Add(new Ban()
                    {
                        Id   = (int)sqlDataReader["Id"],
                        Name = sqlDataReader["Name"].ToString()
                    });
                }
                connection.Close();
                return(bans);
            }
        }
Esempio n. 17
0
        public List <User> GetAll()
        {
            List <User> users = new List <User>();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"SELECT * FROM [User]", connection);

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    users.Add(new User()
                    {
                        Id       = sqlDataReader.GetInt32(0),
                        Name     = sqlDataReader.GetString(1),
                        Password = sqlDataReader.GetString(2)
                    });
                }
                connection.Close();
                return(users);
            }
        }
Esempio n. 18
0
        public Report Get(int id)
        {
            Report report = new Report();

            using (var connection = SqlConnectionContext.Connection())
            {
                SqlCommand sqlCommand = new SqlCommand(@"SELECT Report.Id,Report.SiteTitle,Ban.[Name],Report.[DateTime] FROM Ban INNER JOIN Report ON (Ban.Id=Report.BanID) WHERE Report.Id=@id", connection);
                sqlCommand.Parameters.AddWithValue("@id", id);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.Read())
                {
                    report.Id        = (int)sqlDataReader["Id"];
                    report.SiteTitle = sqlDataReader["SiteTitle"].ToString();
                    report.DateTime  = (DateTime)sqlDataReader["DateTime"];
                    report.Ban       = new Ban()
                    {
                        Name = sqlDataReader["Name"].ToString()
                    };
                }
                connection.Close();
                return(report);
            }
        }