Beispiel #1
0
 public void Delete(Radio entity)
 {
     using (SqlCommand command =
                new SqlCommand("delete from Radios where RadioId=@RadioId "))
     {
         command.Parameters.AddWithValue("@RadioId", entity.RadioId);
         VTYS.SqlExecuteNonQuery(command);
     }
 }
Beispiel #2
0
 public void Add(Post entity)
 {
     using (SqlCommand command = new SqlCommand("insert into Posts (Title,Details) values (@Title,@Details)"))
     {
         command.Parameters.AddWithValue("@Title", entity.Title);
         command.Parameters.AddWithValue("@Details", entity.Details);
         VTYS.SqlExecuteNonQuery(command);
     }
 }
Beispiel #3
0
 public void Update(Post entity)
 {
     using (SqlCommand command = new SqlCommand("update Posts set Title=@Title, Details=@Details where PostId=@PostId"))
     {
         command.Parameters.AddWithValue("@PostId", entity.PostId);
         command.Parameters.AddWithValue("@Title", entity.Title);
         command.Parameters.AddWithValue("@Details", entity.Details);
         VTYS.SqlExecuteNonQuery(command);
     }
 }
Beispiel #4
0
 public void Add(Radio entity)
 {
     using (SqlCommand command =
                new SqlCommand("insert into Radios (Name,Frequency,isOnline) values (@Name,@Frequency,@isOnline)"))
     {
         command.Parameters.AddWithValue("@Name", entity.Name);
         command.Parameters.AddWithValue("@Frequency", entity.Frequency);
         command.Parameters.AddWithValue("@isOnline", entity.isOnline);
         VTYS.SqlExecuteNonQuery(command);
     }
 }
Beispiel #5
0
 public void Update(Radio entity)
 {
     using (SqlCommand command =
                new SqlCommand("update Radios set Name=@Name, Frequency=@Frequency, isOnline=@isOnline where RadioId=@RadioId "))
     {
         command.Parameters.AddWithValue("@RadioId", entity.RadioId);
         command.Parameters.AddWithValue("@Name", entity.Name);
         command.Parameters.AddWithValue("@Frequency", entity.Frequency);
         command.Parameters.AddWithValue("@isOnline", entity.isOnline);
         VTYS.SqlExecuteNonQuery(command);
     }
 }
Beispiel #6
0
        public List <Post> GetAll(Expression <Func <Post, bool> > filter = null)
        {
            var        postList = new List <Post>();
            SqlCommand cmd      = new SqlCommand("Select * from Posts");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Post post = new Post
                {
                    PostId  = Convert.ToInt32(reader[0]),
                    Title   = reader[1].ToString(),
                    Details = reader[2].ToString()
                };

                postList.Add(post);
            }
            return(postList);
        }
Beispiel #7
0
        public List <Radio> GetAll(Expression <Func <Radio, bool> > filter = null)
        {
            var        radioList = new List <Radio>();
            SqlCommand cmd       = new SqlCommand("Select * from Radios");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Radio radio = new Radio
                {
                    RadioId   = Convert.ToInt32(reader[0]),
                    Name      = reader[1].ToString(),
                    Frequency = Convert.ToDouble(reader[2]),
                    isOnline  = (bool)reader[3]
                };

                radioList.Add(radio);
            }
            return(radioList);
        }