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