private async Task CreateCategoryAsync(CategoryEditDto input) { var category = input.MapTo <Category>(); category.TenantId = AbpSession.TenantId.Value; await _categoryRepository.InsertAsync(category); }
private async Task UpdateCategoryAsync(CategoryEditDto input) { var tenantId = AbpSession.TenantId.Value; var category = await _categoryRepository.FirstOrDefaultAsync(c => c.Id == input.Id && c.TenantId == tenantId); input.MapTo(category); }
/// <summary> /// 编辑分类 /// </summary> protected virtual async Task UpdateCategoryAsync(CategoryEditDto input) { var entity = await _categoryRepository.GetAsync(input.Id.Value); input.MapTo(entity); await _categoryRepository.UpdateAsync(entity); }
/// <summary> /// 新增分类 /// </summary> protected virtual async Task <CategoryEditDto> CreateCategoryAsync(CategoryEditDto input) { var entity = input.MapTo <Category>(); entity = await _categoryRepository.InsertAsync(entity); return(entity.MapTo <CategoryEditDto>()); }
public virtual async Task UpdateCategoryAsync(CategoryEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _categoryRepository.GetAsync(input.Id.Value); input.MapTo(entity); await _categoryRepository.UpdateAsync(entity); }
public virtual async Task <CategoryEditDto> CreateCategoryAsync(CategoryEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 var entity = input.MapTo <Category>(); entity = await _categoryRepository.InsertAsync(entity); return(entity.MapTo <CategoryEditDto>()); }
protected virtual async Task Update(CategoryEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _entityRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _entityRepository.UpdateAsync(entity); }
public async Task CreateOrEditAsync(CategoryEditDto dto) { if (_AbpSession.TenantId != null) { dto.TenantId = (int)_AbpSession.TenantId; } else { dto.TenantId = 0; } throw new UserFriendlyException("ss"); if (dto.Id > 0) { await _Repository.UpdateAsync(dto.MapTo <model.Category>()); } else { await _Repository.InsertAsync(dto.MapTo <model.Category>()); } }
protected virtual async Task <CategoryEditDto> Create(CategoryEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 // var entity = ObjectMapper.Map <Category>(input); var entity = input.MapTo <Category>(); entity = await _entityRepository.InsertAsync(entity); return(entity.MapTo <CategoryEditDto>()); }
public async Task CreateOrEditAsync(CategoryEditDto dto) { try { if (dto.Id > 0) { await _Repository.UpdateAsync(dto.MapTo <GoodsCategory>()); } else { if (_AbpSession.TenantId != null) { dto.TenantId = (int)_AbpSession.TenantId; } await _Repository.InsertAsync(dto.MapTo <GoodsCategory>()); } } catch (Exception e) { throw new UserFriendlyException(e.Message); } }
protected async Task UpdateCategoryAsync(CategoryEditDto input) { var model = await _categoryRepository.GetAsync(input.Id.Value); await _categoryRepository.UpdateAsync(input.MapTo(model)); }
protected async Task CreateCategoryAsync(CategoryEditDto input) { await _categoryRepository.InsertAsync(input.MapTo <Category>()); }