コード例 #1
0
        public ActionResult GetAds(int?page, int categoryId = -1, int kindId = -1, int regionId = -1, int tagId = -1)
        {
            ViewBag.Category = categoryId;
            ViewBag.Kind     = kindId;
            ViewBag.Region   = regionId;
            ViewBag.Tag      = tagId;
            int pageSize   = 8;
            int pageNumber = (page ?? 1);

            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <AdDTO, AdVM>();
                cfg.CreateMap <KindDTO, KindVM>();
                cfg.CreateMap <CategoryDTO, CategoryVM>();
                cfg.CreateMap <LocationDTO, LocationVM>();
                cfg.CreateMap <UserDTO, UserVM>()
                .ForMember("ConfirmPassword", opt => opt.Ignore());
                cfg.CreateMap <TagDTO, TagVM>()
                .ForMember(t => t.InfoReviewTags, p => p.Ignore());
                cfg.CreateMap <ImageDTO, ImageVM>();
            });
            //config.AssertConfigurationIsValid();
            var mapper = config.CreateMapper();
            var ads    = mapper.Map <IEnumerable <AdDTO>, IEnumerable <AdVM> >(adService.GetAds((int)categoryId, (int)kindId, (int)regionId, (int)tagId));

            adService.Dispose();
            var adsSort = ads.OrderBy(a => a.DateAdd).Reverse();

            return(PartialView(adsSort.ToPagedList(pageNumber, pageSize)));
        }
コード例 #2
0
        public ActionResult PersonalAds(int?page)
        {
            int id         = User.Identity.GetUserId <int>();
            int pageSize   = 8;
            int pageNumber = (page ?? 1);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <AdDTO, AdVM>();
                cfg.CreateMap <KindDTO, KindVM>();
                cfg.CreateMap <CategoryDTO, CategoryVM>();
                cfg.CreateMap <LocationDTO, LocationVM>();
                cfg.CreateMap <UserDTO, UserVM>()
                .ForMember("ConfirmPassword", opt => opt.Ignore());
                cfg.CreateMap <TagDTO, TagVM>()
                .ForMember(t => t.InfoReviewTags, p => p.Ignore());
                cfg.CreateMap <ImageDTO, ImageVM>();
            });
            //config.AssertConfigurationIsValid();
            var mapper = config.CreateMapper();
            var ads    = mapper.Map <IEnumerable <AdDTO>, IEnumerable <AdVM> >(adService.GetAd(id));

            adService.Dispose();
            return(PartialView(ads.ToPagedList(pageNumber, pageSize)));
        }
コード例 #3
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _adService.Dispose();
             _adService = null;
         }
         this.disposed = true;
     }
 }
コード例 #4
0
        public virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    _adService.Dispose();
                    _prepearingModel.Dispose();
                    _cityService.Dispose();
                    _productModelsService.Dispose();
                    _adViewsService.Dispose();

                    _adService            = null;
                    _prepearingModel      = null;
                    _adFilter             = null;
                    _cityService          = null;
                    _productModelsService = null;
                    _adViewsService       = null;
                }
                this.disposed = true;
            }
        }