コード例 #1
0
        public ActionResult <ParkingBooth> Delete(int id)
        {
            ParkingBooth deletedParkingBooth = _parkingBoothManager.DeleteParkingBooth(id);

            if (deletedParkingBooth == null)
            {
                return(NotFound("No such parking booth, Id: " + id));
            }
            return(Ok(deletedParkingBooth));
        }
コード例 #2
0
        public ActionResult <ParkingBooth> Get(int id)
        {
            ParkingBooth parkingBooth = _parkingBoothManager.GetParkingBoothById(id);

            if (parkingBooth == null)
            {
                return(NotFound("No such id: " + id));
            }
            return(parkingBooth);
        }
コード例 #3
0
 public ActionResult <ParkingBooth> Post([FromBody] ParkingBooth value)
 {
     try
     {
         ParkingBooth newParkingBooth = _parkingBoothManager.AddParkingBooth(value);
         string       uri             = Url.RouteUrl(RouteData.Values) + "/" + newParkingBooth.Id;
         return(Created(uri, newParkingBooth));
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #4
0
 public ActionResult <ParkingBooth> Put(int id, [FromBody] ParkingBooth value)
 {
     try
     {
         ParkingBooth updatedParkingBooth = _parkingBoothManager.UpdateParkingBooth(id, value);
         if (updatedParkingBooth == null)
         {
             return(NotFound("No such parking booth, Id: " + id));
         }
         return(Ok(updatedParkingBooth));
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
 }