public IActionResult AddCar(CarModel carModel) { try { return(Ok(carsLogic.AddCar(carModel))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
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()); } }
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))); } }