Пример #1
0
        //public static List<AdvSumModel> ToDetailAdvertiseSumModel(this List<Advertisement> advertisement)
        //{
        //    List<AdvSumModel> tempList = new List<AdvSumModel>();
        //    foreach (var adv in advertisement)
        //    { AdvSumModel m = new AdvSumModel();
        //        m.Id = adv.ID;
        //        m.Title = adv.Title;
        //        m.Price = adv.price;
        //        m.postedDate = adv.PostedOn;
        //        m.ImgUrl = (adv.Images.Count > 0) ? adv.Images.First().Url : "/Images/temp/nophoto.png";
        //        tempList.Add(m);
        //    }
        //    tempList.TrimExcess();
        //    return tempList;
        //}

        public static AdvSumModel DetailAdv(Advertisement a)
        {
            AdvSumModel tem = new AdvSumModel();

            tem.Id     = a.ID;
            tem.ImgUrl = (a.Images.Count > 0) ? a.Images.First().Url : "/Images/temp/nophoto.png";
            tem.Price  = a.price;


            return(tem);
        }
Пример #2
0
        public static List <AdvSumModel> ToAdvertiseSumModel(this List <Advertisement> advertisement)
        {
            List <AdvSumModel> tempList = new List <AdvSumModel>();

            foreach (var adv in advertisement)
            {
                AdvSumModel m = new AdvSumModel();
                m.Id         = adv.ID;
                m.Title      = adv.Title;
                m.Price      = adv.price;
                m.postedDate = adv.PostedOn;
                m.Cat        = adv.SubCatagory.Catagory.Name;
                m.Status     = adv.Status.Name;

                m.ImgUrl = (adv.Images.Count > 0) ? adv.Images.First().Url : "/Images/temp/nophoto.png";
                tempList.Add(m);
            }
            tempList.TrimExcess();
            return(tempList);
        }