コード例 #1
0
        public void Post([FromBody] Person value)
        {
            var people = context.Set <Person>();

            people.Add(value);
            context.SaveChanges();
        }
コード例 #2
0
        public Person Add([FromBody] Person person)
        {
            var newPerson = person;
            var a         = azureDbContext.People.Add(person);

            azureDbContext.SaveChanges();
            return(a.Entity);
        }
コード例 #3
0
 public IActionResult Create([FromBody] Person person)
 {
     if (ModelState.IsValid)
     {
         context.People.Add(person);
         context.SaveChanges();
         return(Ok(person));
     }
     return(BadRequest("Person creation failed"));
 }
コード例 #4
0
        public IActionResult POST()
        {
            Person person = new Person
            {
                FirstName = Request.Form["firstName"],
                LastName  = Request.Form["lastName"]
            };

            db.People.Add(person);
            db.SaveChanges();
            return(Ok(person));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
 public IActionResult Create([FromBody] Person person)
 {
     _azureDbContext.People.Add(person);
     _azureDbContext.SaveChanges();
     return(Ok(person.PersonId));
 }
コード例 #9
0
 public IActionResult Create([FromBody] Person person)
 {
     db.People.Add(person);
     db.SaveChanges();
     return(Ok());
 }