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