Exemple #1
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="_AdvertisementVM"></param>
        /// <returns></returns>
        public ActionResult Edit(AdvertisementVM _AdvertisementVM)
        {
            _AdvertisementVM.Advertisement = _AdvertisementService.GetById(_AdvertisementVM.Id) ?? new Advertisement();

            _AdvertisementVM.ImgInfo = _imageInfoService.GetById(_AdvertisementVM.Advertisement.ImageInfoId) ?? new ImageInfo();
            return(View(_AdvertisementVM));
        }
        public IResponseDTO DeleteAdvertisement(AdvertisementVM model)
        {
            try
            {
                var DbAdvertisement = _mapper.Map <Advertisement>(model);
                var entityEntry     = _AdvertisementRepositroy.Remove(DbAdvertisement);


                int save = _unitOfWork.Commit();

                if (save == 200)
                {
                    _response.Data     = null;
                    _response.IsPassed = true;
                    _response.Message  = "Ok";
                }
                else
                {
                    _response.Data     = null;
                    _response.IsPassed = false;
                    _response.Message  = "Not saved";
                }
            }
            catch (Exception ex)
            {
                _response.Data     = null;
                _response.IsPassed = false;
                _response.Message  = "Error " + ex.Message;
            }
            return(_response);
        }
Exemple #3
0
        /// <summary>
        /// 获取单条广告进行编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> GetAdvertisement(Guid id)
        {
            var entity = await _advertisement.GetSingleAsyn(id);

            var viewModel = new AdvertisementVM(entity);

            viewModel.Image = _businessImage.GetSingleBy(x => x.RelevanceObjectId == entity.Id);
            return(PartialView("../../Views/AdminCenter/_EditAdvertisementPartialModal", viewModel));
        }
Exemple #4
0
        public async Task <IActionResult> EditAdvertisement(AdvertisementVM input)
        {
            var entity = await _advertisement.GetSingleAsyn(input.Id);

            entity.Link = input.Link;
            var r = await _advertisement.AddOrEditAndSaveAsyn(entity);

            if (r)
            {
                UploadAdvertisementIMG(entity);
                return(Json(new { result = true }));
            }
            return(Json(new { result = false, messages = "失败的操作!" }));
        }
        /// <summary>
        /// 获取广告和轮播
        /// </summary>
        public void GetAdvertisements()
        {
            var advertisementsVM = new List <AdvertisementVM>();
            var advertisements   = _advertisement.GetAll();

            foreach (var advertisement in advertisements)
            {
                var advertisementVM = new AdvertisementVM(advertisement);
                var image           = _businessImage.GetSingleBy(x => x.RelevanceObjectId == advertisement.Id);
                advertisementVM.Image = image;
                advertisementsVM.Add(advertisementVM);
            }
            ViewBag.Advertisements = advertisementsVM;
        }
Exemple #6
0
        public async Task <IActionResult> Advertisements()
        {
            var entities = await _advertisement.GetAllListAsyn();

            var advertisementVMs = new List <AdvertisementVM>();
            int counter          = 0;

            foreach (var item in entities)
            {
                var advertisementVM = new AdvertisementVM(item);
                advertisementVM.Image       = _businessImage.GetSingleBy(x => x.RelevanceObjectId == item.Id);
                advertisementVM.OrderNumber = (++counter).ToString();
                advertisementVMs.Add(advertisementVM);
            }
            return(View(advertisementVMs));
        }
Exemple #7
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="_AdvertisementVM"></param>
        /// <param name="pn"></param>
        /// <returns></returns>
        public ActionResult List(AdvertisementVM _AdvertisementVM, int pn = 1)
        {
            int totalCount,
                pageIndex = pn,
                pageSize  = PagingConfig.PAGE_SIZE;
            var list      = _AdvertisementService.GetManagerList(_AdvertisementVM.QueryName, _AdvertisementVM.Type, pageIndex, pageSize, out totalCount);
            var paging    = new Paging <Advertisement>()
            {
                Items = list,
                Size  = PagingConfig.PAGE_SIZE,
                Total = totalCount,
                Index = pn,
            };

            _AdvertisementVM.Paging = paging;
            return(View(_AdvertisementVM));
        }
        public IResponseDTO RemoveAdvertisement(AdvertisementVM AdvertisementVM)
        {
            var depart = _AdvertisementServices.DeleteAdvertisement(AdvertisementVM);

            return(depart);
        }