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