Exemplo n.º 1
0
        public async Task <IActionResult> PutCar(int id, Car car)
        {
            if (id != car.car_Id)
            {
                return(BadRequest());
            }

            if (_context.CarDB.Any(c => (c.car_Number.Equals(car.car_Number)) && (c.car_Id != id)))
            {
                return(BadRequest("Car Number already exists. Please enter a different Car Number."));
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutCarType(int id, CarType carType)
        {
            if (id != carType.carType_Id)
            {
                return(BadRequest());
            }

            if (_context.CarTypeDB.Any(c => (c.carType_Name.Equals(carType.carType_Name)) && (c.carType_Id != id)))
            {
                return(BadRequest("Car Type already exists."));
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutEmployee(int id, Employee employee)
        {
            if (id != employee.employee_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }