public VersionMigrationContext Setup(ModerationItem moderationItem) { ModerationItem = moderationItem ?? throw new ArgumentException(nameof(moderationItem)); EntityMigrationContext = moderationItem.Type switch { ModerationTypes.Technique => new TechniqueMigrationContext(_ctx), ModerationTypes.Category => new CategoryMigrationContext(_ctx), ModerationTypes.SubCategory => new SubCategoryMigrationContext(_ctx), _ => throw new ArgumentException(nameof(moderationItem.Type)) }; return(this); }
/// <summary> /// Method performs the operation /// </summary> /// <param name="context">context</param> public static async Task SeedData(DataContext context) { if (!context.ModerationItems.Any()) { var bookId = context.Books.Where(book => book.Title.Equals("Book Current")).First().Id; var moderation = new ModerationItem { Target = bookId, Type = ModerationTypes.Book }; await context.ModerationItems.AddAsync(moderation); await context.SaveChangesAsync(); } }