public static void Seed(this ProductionsContext context) { context.ProductionAreas.RemoveRange(context.ProductionAreas); context.Stores.RemoveRange(context.Stores); context.SaveChanges(); var productionTxt = File.ReadAllText("production.json"); var production = JsonConvert.DeserializeObject <List <Model.ProductionArea> >(productionTxt); var storeTxt = File.ReadAllText("store.json"); var store = JsonConvert.DeserializeObject <List <Model.Store> >(storeTxt); context.Stores.AddRange(store); context.ProductionAreas.AddRange(production); context.SaveChanges(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ProductionsContext productionsContext, INewOrderService newOrderService, IOrderPaidService orderPaidService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "GeekBurger Production API V1"); }); productionsContext.Seed(); newOrderService.SubscribeToTopic("NewOrder"); orderPaidService.SubscribeToTopic("OrderChanged"); }
/// <summary> /// Build all rules for nonterminal /// </summary> /// <param name="grammarRuleContext"></param> private void BuildGrammarRule(GrammarRuleContext grammarRuleContext) { string name = grammarRuleContext.grammarName().GetText(); //save start rule if (firstRuleName.Equals("")) { firstRuleName = name; } if (NonTerminals.ContainsKey(name)) { throw new GrammarBuilderException($"Nonterminal {name} is defined twice"); } var nonTerminal = NonTerminals[name] = new NonTerminal(name); ProductionsContext productions = grammarRuleContext.productions(); do { nonTerminal.Productions.Add(BuildProduction(productions.production())); productions = productions.productions(); } while (productions != null); }