Ejemplo n.º 1
0
        public ActionResult <Car> Delete(int id)
        {
            Car deletedCar = _manager.DeleteCar(id);

            if (deletedCar == null)
            {
                return(NotFound("No such car, id: " + id));
            }
            return(Ok(deletedCar));
        }
        // DELETE: api/Cars/5
        public HttpResponseMessage Delete(string licencenumber)
        {
            bool           Result      = CarManager.DeleteCar(licencenumber);
            HttpStatusCode responsCode = Result ? HttpStatusCode.OK : HttpStatusCode.BadRequest;

            return(new HttpResponseMessage(responsCode)
            {
                Content = new ObjectContent <bool>(Result, new JsonMediaTypeFormatter())
            });
        }
Ejemplo n.º 3
0
        // DELETE api/car/5
        /// <param name="id"></param>
        public void DeleteCar(int id)
        {
            Car car = CarManager.GetById(id);

            if (car != null)
            {
                CarManager.DeleteCar(car.Id);
            }
            else
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
        }
Ejemplo n.º 4
0
        public ActionResult DeleteCar(string carId)
        {
            bool result = CarManager.DeleteCar(carId);

            if (result)
            {
                ViewBag.message = "Car successfully deleted.";
            }
            else
            {
                ViewBag.message = "Car could not be deleted.";
            }

            return(View(CarPersistence.GetUserCar(Session["UserId"].ToString())));
        }
 public HttpResponseMessage DeleteCar([FromUri] int id)
 {
     try
     {
         if (logic.DeleteCar(id))
         {
             return(Request.CreateResponse(HttpStatusCode.OK, true));
         }
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, new HttpError()));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
 public HttpResponseMessage DeleteCar([FromUri] int id)
 {
     using (logic = new CarManager())
     {
         try
         {
             bool isDelete = logic.DeleteCar(id);
             return(Request.CreateResponse(HttpStatusCode.OK, isDelete));
         }
         catch (Exception ex)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ExceptionHelper.GetInnerMessage(ex)));
         }
     }
 }