public void Post([FromBody] Person value) { var people = context.Set <Person>(); people.Add(value); context.SaveChanges(); }
public Person Add([FromBody] Person person) { var newPerson = person; var a = azureDbContext.People.Add(person); azureDbContext.SaveChanges(); return(a.Entity); }
public IActionResult Create([FromBody] Person person) { if (ModelState.IsValid) { context.People.Add(person); context.SaveChanges(); return(Ok(person)); } return(BadRequest("Person creation failed")); }
public IActionResult POST() { Person person = new Person { FirstName = Request.Form["firstName"], LastName = Request.Form["lastName"] }; db.People.Add(person); db.SaveChanges(); return(Ok(person)); }
public IActionResult Create([FromBody] AZObsItem item) { if (item == null) { return(BadRequest()); } _context.AZObsItems.Add(item); _context.SaveChanges(); GeneralDB.UpdateLocation(_context, "AZObsItems", item.Geo, item.Id); return(CreatedAtRoute("GetAZObs", new { id = item.Id }, item)); }
public AZObsController(AzureDbContext context) { _context = context; //create at least one item if (_context.AZObsItems.Count() == 0) { _context.AZObsItems.Add(new AZObsItem { Name = "Item1" }); _context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new AzureDbContext( serviceProvider.GetRequiredService <DbContextOptions <AzureDbContext> >())) { if (context.EmployeeDetail.Any()) { return; } context.EmployeeDetail.AddRange( new EmployeeDetail { Name = "Sorav Thakur", EmailAddress = "*****@*****.**" }, new EmployeeDetail { Name = "Demo", EmailAddress = "*****@*****.**" } ); context.SaveChanges(); } }
public IActionResult Create([FromBody] Person person) { _azureDbContext.People.Add(person); _azureDbContext.SaveChanges(); return(Ok(person.PersonId)); }
public IActionResult Create([FromBody] Person person) { db.People.Add(person); db.SaveChanges(); return(Ok()); }