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