示例#1
0
        public BannerDto getById(int id)
        {
            Banner banner = bannerDAL.getById(id);

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Banner, BannerDto>();
            });
            BannerDto bannerDto = Mapper.Map <BannerDto>(banner);

            return(bannerDto);
        }
示例#2
0
        public BannerDto insert(BannerDto bannerDto, int createUserId)
        {
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <BannerDto, Banner>();
            });
            Banner banner = Mapper.Map <Banner>(bannerDto);

            banner.CreateUserId = createUserId;
            if (bannerDAL.insert(banner) > 0)
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <Banner, BannerDto>();
                });
                return(Mapper.Map <BannerDto>(banner));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        public BannerDto update(BannerDto bannerDto, int updateUserId)
        {
            Banner banner = bannerDAL.getById(bannerDto.Id);

            banner.Type         = bannerDto.Type;
            banner.ImageSrc     = bannerDto.ImageSrc;
            banner.Link         = bannerDto.Link;
            banner.Status       = bannerDto.Status;
            banner.OrderByNum   = bannerDto.OrderByNum;
            banner.UpdateUserId = updateUserId;
            if (bannerDAL.update(banner) > 0)
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <Banner, BannerDto>();
                });
                return(Mapper.Map <BannerDto>(banner));
            }
            else
            {
                return(null);
            }
        }