protected virtual async Task CreateUserAsync(CreateOrEditCityDto input) { var entity = ObjectMapper.Map <City>(input); await cityRepository.InsertAndGetIdAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); }
protected virtual async Task UpdateAsync(CreateOrEditCityDto input) { var entity = await cityRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == input.Id); ObjectMapper.Map(input, entity); await cityRepository.UpdateAsync(entity); }
//[AbpAuthorize(PermissionNames.AdminPage_City)] public async Task CreateOrUpdate(CreateOrEditCityDto input) { if (input.Id != 0) { await UpdateAsync(input); } else { await CreateUserAsync(input); } }
public async Task CreateOrEdit(CreateOrEditCityDto input) { if (input.Id == null) { await Create(input); } else { await Update(input); } }
protected virtual async Task Create(CreateOrEditCityDto input) { var city = ObjectMapper.Map <City>(input); if (AbpSession.TenantId != null) { city.TenantId = (int)AbpSession.TenantId; } await _cityRepository.InsertAsync(city); }
public async Task <CreateOrEditCityDto> GetForEdit(int?id) { var model = new CreateOrEditCityDto(); if (id == null) { return(model); } var entity = await cityRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == id); entity.MapTo(model); //model = model.Translations // .Concat(translations) // .DistinctBy(p => p.Language) // .ToList(); return(model); }
private async Task Create(CreateOrEditCityDto input) { var city = ObjectMapper.Map <City>(input); await _cityRepository.InsertAsync(city); }
private async Task Update(CreateOrEditCityDto input) { var city = await _cityRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, city); }