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