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