Example #1
0
 /// <summary>
 /// 新增或更改页面
 /// </summary>
 public async Task CreateOrUpdatePage(PageUpdateDto input)
 {
     input.Remarks = HttpUtility.UrlDecode(input.Remarks);
     if (input.Id == 0)
     {
         var entity = await CreatePage(input);
     }
     else
     {
         await UpdatePage(input);
     }
 }
Example #2
0
        /// <summary>
        /// 新增页面
        /// </summary>
        public virtual async Task <Page> CreatePage(PageUpdateDto input)
        {
            if (input.PageType != 5)
            {
                var PageList = _pageRepository.GetAll().Where(p => p.PageType == input.PageType && p.StoreId == input.StoreId && p.PagePosition == input.PagePosition).ToList();
                foreach (var item in PageList)
                {
                    if (item.Status == 2 && input.Status == 2)
                    {
                        throw new UserFriendlyException("该页面已有发布页面!");
                    }
                }
            }
            var entity = await _pageRepository.InsertAsync(input.MapTo <Page>());

            // CacheService.Set(input.Id, input.MapTo(entity));
            return(entity);
        }
Example #3
0
        /// <summary>
        /// 更新页面
        /// </summary>
        public virtual async Task UpdatePage(PageUpdateDto input)
        {
            if (input.PageType != 5)
            {
                var PageList = _pageRepository.GetAll().Where(p => p.PageType == input.PageType && p.StoreId == input.StoreId && p.PagePosition == input.PagePosition).ToList();
                foreach (var item in PageList)
                {
                    if (item.Status == 2 && item.Id != input.Id && input.Status == 2)
                    {
                        throw new UserFriendlyException("该页面已有发布页面!");
                    }
                }
            }
            var entity = await _pageRepository.GetAsync(input.Id);

            await _pageRepository.UpdateAsync(input.MapTo(entity));

            //await CurrentUnitOfWork.SaveChangesAsync();
            //entity = await _pageRepository.GetAsync(input.Id);

            CacheService.Set(input.Id, input.MapTo(entity));
        }