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