public async Task <IActionResult> PutPerson(int id, Person person)
        {
            if (id != person.PersonId)
            {
                return(BadRequest());
            }

            _context.Entry(person).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Person> > Create([FromBody] Person person)
        {
            _azureDbContext.People.Add(person);
            await _azureDbContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = person.PersonId }));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,EmailAddress")] EmployeeDetail employeeDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employeeDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employeeDetail));
        }
Exemple #5
0
        public async Task AddAsync(Person person)
        {
            await _context.AddAsync(person);

            await _context.SaveChangesAsync();
        }
Exemple #6
0
 public async Task <bool> SaveChangesAsync()
 {
     return(await _context.SaveChangesAsync() > 0);
 }