コード例 #1
0
 public IActionResult AddCar(CarModel carModel)
 {
     try
     {
         return(Ok(carsLogic.AddCar(carModel)));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
コード例 #2
0
        public IHttpActionResult AddCar(string carNumber, int currentMiles, string imageFileName, bool isOK2Rent,
                                        int carModelID, int year, int gearTypeID, int dailyCost, int dailyLateCost)
        {
            CarsLogic cars   = new CarsLogic();
            var       result = cars.AddCar(carNumber, currentMiles, imageFileName, isOK2Rent,
                                           carModelID, year, gearTypeID, dailyCost, dailyLateCost);

            if (result == 2)
            {
                return(Ok(result));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #3
0
ファイル: CarsController.cs プロジェクト: gio-pumi/RentCar
        public HttpResponseMessage AddCar(carDTO car)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest,
                                                  ErrorsManager.GetErrors(ModelState)));
                }

                string addedCar = logic.AddCar(car);

                return(Request.CreateResponse(HttpStatusCode.Created, addedCar));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.InternalServerError,
                           ErrorsManager.GetInnerMessage(ex)));
            }
        }