public async Task <ActionResult <Object> > PostObject(Object @object) { _context.Object.Add(@object); await _context.SaveChangesAsync(); return(CreatedAtAction("GetObject", new { id = @object.Id }, @object)); }
// GET: Building/Create public ActionResult Create() { for (int i = 0; i < 100; i++) { Object ob = new Object(); ob.Name = "Building - " + i; _context.Object.Add(ob); DataField df = new DataField(); df.Name = "DataField - " + i; _context.DataField.Add(df); _context.SaveChanges(); } //for (int i = 0; i < 100; i++) //{ // Building building = new Building(); // building.Name = "Building - " + i; // building.Location = "Location - "+i; // _context.Building.Add(building); // DataField df = new DataField(); // df.Name = "DataField - " + i; // _context.DataField.Add(df); // _context.SaveChanges(); //} return(View()); }
public async Task <IActionResult> PutObject(int id, Object @object) { if (id != @object.Id) { return(BadRequest()); } _context.Entry(@object).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ObjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }