public void Post([FromBody] Person value)
        {
            var people = context.Set <Person>();

            people.Add(value);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public Person Add([FromBody] Person person)
        {
            var newPerson = person;
            var a         = azureDbContext.People.Add(person);

            azureDbContext.SaveChanges();
            return(a.Entity);
        }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 8
0
 public IActionResult Create([FromBody] Person person)
 {
     _azureDbContext.People.Add(person);
     _azureDbContext.SaveChanges();
     return(Ok(person.PersonId));
 }
Ejemplo n.º 9
0
 public IActionResult Create([FromBody] Person person)
 {
     db.People.Add(person);
     db.SaveChanges();
     return(Ok());
 }