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