public async Task SaveAsync(Citizenship entity) { try { if (entity == null) { return; } using (var timeLineContext = _contextFactory.GetTimeLineContext()) { var entityModel = await timeLineContext .Citizenships .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id)); if (entityModel == null) { entityModel = new DA.Citizenship(); MapForUpdateentity(entity, entityModel); await timeLineContext.Citizenships.AddAsync(entityModel); } else { MapForUpdateentity(entity, entityModel); } timeLineContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
private void MapForUpdateentity(Citizenship entity, DA.Citizenship daEntity) { daEntity.Id = entity.Id; }