Ejemplo n.º 1
0
        public async Task <IActionResult> PutEmployee(long id, Employee employee)
        {
            if (id != employee.EmployeeId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutCompany(long id, Company company)
        {
            if (id != company.Id)
            {
                return(BadRequest());
            }

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

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

            return(CreatedAtAction("GetCompany", new { id = company.Id }, "Id: " + company.Id + " updated"));
        }