public async Task <ApiRequestResult> UpdateAsync(ProductAttributeDto dto) { var entity = await _productAttributeRepository.GetAsync(dto.Id.Value); var newEntity = dto.EntityMap(entity); await _productAttributeRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public async Task <BasePageList <ProductAttributeResult> > GetAsync(ProductAttributeFilter filter) { var attributesPageList = await _productAttributeRepository.GetAsync(filter); var createdByIds = attributesPageList.Collections.Select(x => x.CreatedById).ToArray(); var updatedByIds = attributesPageList.Collections.Select(x => x.UpdatedById).ToArray(); var createdByUsers = await _userRepository.GetNameByIdsAsync(createdByIds); var updatedByUsers = await _userRepository.GetNameByIdsAsync(updatedByIds); foreach (var category in attributesPageList.Collections) { var createdBy = createdByUsers.FirstOrDefault(x => x.Id == category.CreatedById); category.CreatedBy = createdBy.DisplayName; var updatedBy = updatedByUsers.FirstOrDefault(x => x.Id == category.CreatedById); category.UpdatedBy = updatedBy.DisplayName; } return(attributesPageList); }