private void LoadTextVersions(TextDbContext context, TextModuleDbEntity textDbEntity) { if (textDbEntity != null) { textDbEntity.TextVersions = context.TextVersions .Include(y => y.TextLocalisations) .Where(x => x.TextModuleId == textDbEntity.Id && x.Status != TextVersionStatus.Deleted) .ToList(); } }
private void UpdateTextVersionLocalisations(TextDbContext context, ICollection <TextLocalisation> textVersionLocalisations) { foreach (var textVersionLocalisation in textVersionLocalisations) { var textVersionLocalisationDbEntity = context.TextLocalisations .FirstOrDefault(x => x.TextVersionId == textVersionLocalisation.TextVersionId && x.LanguageId == textVersionLocalisation.LanguageId); if (textVersionLocalisationDbEntity == null) { context.TextLocalisations.Add(_mapper.Map <TextLocalisationDbEntity>(textVersionLocalisation)); } else { textVersionLocalisationDbEntity.Content = textVersionLocalisation.Content; } } }
private void UpdateTextVersions(TextDbContext context, IList <TextVersion> textVersions) { foreach (var textVersion in textVersions) { var textVersionDbEntity = context.TextVersions.FirstOrDefault(x => x.Id == textVersion.Id); if (textVersionDbEntity == null) { context.TextVersions.Add(_mapper.Map <TextVersionDbEntity>(textVersion)); } else { textVersionDbEntity.Description = textVersion.Description; textVersionDbEntity.Content = textVersion.Content; textVersionDbEntity.Status = textVersion.Status; UpdateTextVersionLocalisations(context, textVersion.TextLocalisations); } } }