/// <summary> /// 新增页面元素 /// </summary> public virtual async Task <PageElementDto> CreatePageElement(PageElementUpdateDto input) { //if (await _pageElementRepository.IsExistsPageElementByName(input.CategoryName)) //{ // throw new UserFriendlyException(L("NameIsExists")); //} var entity = await _pageElementRepository.InsertAsync(input.MapTo <PageElement>()); return(entity.MapTo <PageElementDto>()); }
/// <summary> /// 更新页面元素 /// </summary> public virtual async Task UpdatePageElement(PageElementUpdateDto input) { //if (await _pageElementRepository.IsExistsPageElementByName(input.CategoryName, input.Id)) //{ // throw new UserFriendlyException(L("NameIsExists")); //} var entity = await _pageElementRepository.GetAsync(input.Id); await _pageElementRepository.UpdateAsync(input.MapTo(entity)); }
/// <summary> /// 新增或更改页面元素 /// </summary> public async Task CreateOrUpdatePageElement(PageElementUpdateDto input) { input.CustomContent = HttpUtility.UrlDecode(input.CustomContent); if (input.Id == 0) { await CreatePageElement(input); } else { await UpdatePageElement(input); } }