コード例 #1
0
 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();
     }
 }
コード例 #2
0
        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;
                }
            }
        }
コード例 #3
0
        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);
                }
            }
        }