예제 #1
0
 private language_versions MapVersions(languages language)
 {
     return(new language_versions
     {
         LanguageId = language.Id,
         Name = language.Name,
         Description = language.Description,
         Version = language.Version,
         CreatedAt = language.CreatedAt,
         UpdatedAt = language.UpdatedAt,
         WorkflowState = language.WorkflowState
     });
 }
예제 #2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            languages language = await dbContext.languages.FirstOrDefaultAsync(x => x.Id == Id);

            if (language == null)
            {
                throw new NullReferenceException($"Could not find language with Id: {Id}");
            }

            language.WorkflowState = Constants.Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                language.Version  += 1;
                language.UpdatedAt = DateTime.UtcNow;

                dbContext.language_versions.Add(MapVersions(language));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
예제 #3
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            languages languages = await dbContext.languages.FirstOrDefaultAsync(x => x.Id == Id);

            if (languages == null)
            {
                throw new NullReferenceException($"Could not find language wit Id: {Id}");
            }

            languages.Name        = Name;
            languages.Description = Description;

            if (dbContext.ChangeTracker.HasChanges())
            {
                languages.Version  += 1;
                languages.UpdatedAt = DateTime.UtcNow;

                dbContext.language_versions.Add(MapVersions(languages));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }