Exemplo n.º 1
0
 public Tuple<model.Product, List<model.ImageList>> Details(string id)
 {
     var sqlProduct = "select * from Product where Id='" + id + "'";
     var sqlImgList = "select * from ImageList where ProductId='" + id + "'";
     var product = new model.Product();
     using (var sReader = SqlDBHelper.ExecuteReader(sqlProduct))
     {
         while (sReader.Read())
         {
             product.Id = sReader["Id"].ToString();
             product.CategoryId = sReader["CategoryId"].ToString();
             product.Name = sReader["Name"].ToString();
             product.Description = sReader["Description"].ToString();
             product.ImgSrc = sReader["ImgSrc"].ToString();
             product.CreateTime = Convert.ToDateTime(sReader["CreateTime"]);
         }
     }
     List<model.ImageList> list = new List<model.ImageList>();
     using (var sReader = SqlDBHelper.ExecuteReader(sqlImgList))
     {
         while (sReader.Read())
         {
             var img = new model.ImageList
             {
                 Id = sReader["Id"].ToString(),
                 ProductId = sReader["ProductId"].ToString(),
                 ImgSrc = sReader["ImgSrc"].ToString()
             };
             list.Add(img);
         }
     }
     return Tuple.Create<model.Product, List<model.ImageList>>(product, list);
 }
Exemplo n.º 2
0
 public List<model.ImageList> GetList(int page, int size, string productId, out int total)
 {
     var sql = "select * from ImageList where ProductId='" + productId + "'";
     List<model.ImageList> list = new List<model.ImageList>();
     using (var sReader = SqlDBHelper.ExecuteReader(sql))
     {
         while (sReader.Read())
         {
             var product = new model.ImageList
             {
                 Id = sReader["Id"].ToString(),
                 ImgSrc = sReader["ImgSrc"].ToSafeTrim(),
                 ProductId = sReader["ProductId"].ToSafeTrim()
             };
             list.Add(product);
         }
     }
     total = list.Count;
     return list.Skip(size * (page - 1)).Take(size).ToList();
 }