public IEnumerable <Mount> Get() { using (var db = new CollectorContext()) { return(db.Mount.ToList()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } using (var context = new CollectorContext()) { context.Database.Migrate(); } app.UseMvc(); }
public override Resultset Get(QueryContext queryContext, object[] parameters) { if (ChildNodes.Count != 1) throw new InvalidOperationException(); Resultset source = ChildNodes[0].Get(queryContext, parameters); DataTable dt = RowType.CreateSchemaTable(); DataRow r = dt.NewRow(); r["ColumnName"] = _tableName; r["ColumnOrdinal"] = 0; r["DataType"] = typeof(Row); r["NestedType"] = source.RowType; dt.Rows.Add(r); CollectorContext context = new CollectorContext(this, source, parameters); return new Resultset(new RowType(dt), context); }
public Mount[] AddAndUpdateMounts() { using (var client = new HttpClient()) { var result = client.GetAsync("http://api.xivdb.com/mount/").Result; var json = result.Content.ReadAsStringAsync(); var jsonObject = JsonConvert.DeserializeObject <JArray>(json.Result); using (var db = new CollectorContext()) { foreach (var mountJsonObject in jsonObject) { var id = mountJsonObject.Value <int>("id"); var name = mountJsonObject.Value <string>("name"); var mount = new Mount { Id = id, Name = name }; db.Mount.AddOrUpdate(mount, m => m.Id == id); db.SaveChanges(); } return(db.Mount.ToArray()); } } }