Example #1
0
 public void Delete(Post entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("DELETE FROM Posts WHERE PostId = @PostId"))
     {
         cmd.Parameters.AddWithValue("PostId", entity.PostId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #2
0
 public void Delete(Clothe entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("DELETE FROM Clothes WHERE ClotheId = @ClotheId"))
     {
         cmd.Parameters.AddWithValue("ClotheId", entity.ClotheId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #3
0
 public void Add(Clothe entity)
 {
     using (SqlCommand cmd = new SqlCommand("INSERT INTO Clothes (Name,UnitPrice) " +
                                            "VALUES(@Name,@UnitPrice)"))
     {
         cmd.Parameters.AddWithValue("Name", entity.Name);
         cmd.Parameters.AddWithValue("UnitPrice", entity.UnitPrice);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #4
0
 public void Update(Clothe entity)
 {
     using (SqlCommand cmd = new SqlCommand("UPDATE Clothes set Name = @Name, UnitPrice=@UnitPrice WHERE ClotheId = @ClotheId"))
     {
         cmd.Parameters.AddWithValue("@ClotheId", entity.ClotheId);
         cmd.Parameters.AddWithValue("@Name", entity.Name);
         cmd.Parameters.AddWithValue("@UnitPrice", entity.UnitPrice);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #5
0
 public void Add(Post entity)
 {
     using (SqlCommand cmd = new SqlCommand("INSERT INTO Posts (Title,Details) " +
                                            "VALUES(@Title,@Details)"))
     {
         cmd.Parameters.AddWithValue("Title", entity.Title);
         cmd.Parameters.AddWithValue("Details", entity.Details);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #6
0
 public void Update(Post entity)
 {
     using (SqlCommand cmd = new SqlCommand("UPDATE Posts set Title = @Title, Details=@Details WHERE PostId = @PostId"))
     {
         cmd.Parameters.AddWithValue("@PostId", entity.PostId);
         cmd.Parameters.AddWithValue("@Title", entity.Title);
         cmd.Parameters.AddWithValue("@Details", entity.Details);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Example #7
0
        public List <Clothe> GetAll(Expression <Func <Clothe, bool> > filter = null)
        {
            List <Clothe> clotheList = new List <Clothe>();
            SqlCommand    cmd        = new SqlCommand("Select * from Clothes");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Clothe clothe = new Clothe
                {
                    ClotheId  = Convert.ToInt32(reader[0]),
                    Name      = reader[1].ToString(),
                    UnitPrice = Convert.ToDecimal(reader[2])
                };

                clotheList.Add(clothe);
            }

            return(filter == null ? clotheList : clotheList.Where(filter.Compile()).ToList());
        }
Example #8
0
        public List <Post> GetAll(Expression <Func <Post, bool> > filter = null)
        {
            List <Post> 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(filter == null ? postList : postList.Where(filter.Compile()).ToList());
        }