Ejemplo n.º 1
0
        public static List <Advert> QueryAdvertDetailForService(int id, string category)
        {
            try
            {
                List <Advert>         adverts = new List <Advert>();
                SP.ListItemCollection coll    = DAT.DataQuery.QueryListItems(BillBoardModel.advertsSiteUrl, BillBoardModel.sayfalarListName, string.Format(BillBoardModel.advertDetailForServiceCamlQuery, category, id));
                if (coll.Count > 0)
                {
                    var    item = coll[0];
                    Advert adv  = new Advert();
                    adv.Category    = category;
                    adv.ID          = id;
                    adv.Title       = item["Title"].ToString();
                    adv.Price       = Convert.ToDecimal(item["Price"]);
                    adv.Created     = Convert.ToDateTime(item["Created"]);
                    adv.Description = item["GenericDescription"].ToString();
                    adv.Detail      = item["GenericDetail"].ToString();

                    // Retrieve Images
                    List <string> imageServerUrls = DAT.DataQuery.QueryFolderFileUrls(BillBoardModel.advertsSiteUrl, BillBoardModel.goruntulerListName, id.ToString());
                    if (imageServerUrls.Count > 0)
                    {
                        List <string> urlPaths = new List <string>();

                        foreach (var imgUrl in imageServerUrls)
                        {
                            urlPaths.Add(HLP.ResizeAndSaveRemoteImageToLocalForService(imgUrl, 200, 100, 14, adv.GetType().Name.ToString() + id));
                        }

                        adv.ImageUrls = urlPaths;
                    }

                    adverts.Add(adv);
                }

                return(adverts);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }