Esempio n. 1
0
        public ActionResult DeleteCar(int id, [FromQuery] int key)
        {
            if (!ManagementHelper.IsAdministrator(key))
            {
                return(Forbid());
            }

            try
            {
                _carRepository.DeleteCar(id);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
Esempio n. 2
0
        public ActionResult EditCar(int id, [FromBody, Required] Car car, [FromQuery] int key)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ManagementHelper.IsAdministrator(key))
            {
                return(Forbid());
            }

            try
            {
                _carRepository.UpdateCar(car);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(Ok());
        }