protected virtual async Task CreateUserAsync(CreateOrEditKnowledgeDto input) { var entity = ObjectMapper.Map <Knowledge>(input); await knowledgeRepository.InsertAndGetIdAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); }
protected virtual async Task UpdateAsync(CreateOrEditKnowledgeDto input) { var entity = await knowledgeRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == input.Id); ObjectMapper.Map(input, entity); await knowledgeRepository.UpdateAsync(entity); }
//[AbpAuthorize(PermissionNames.AdminPage_Knowledge)] public async Task CreateOrUpdate(CreateOrEditKnowledgeDto input) { if (input.Id != 0) { await UpdateAsync(input); } else { await CreateUserAsync(input); } }
public async Task <CreateOrEditKnowledgeDto> GetForEdit(int?id) { var model = new CreateOrEditKnowledgeDto(); if (id == null) { return(model); } var entity = await knowledgeRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == id); entity.MapTo(model); //model = model.Translations // .Concat(translations) // .DistinctBy(p => p.Language) // .ToList(); return(model); }