Beispiel #1
0
 public IActionResult Put(int id, [FromBody] TouristSpotModelIn dataToUpdate)
 {
     try
     {
         var touristSpot = dataToUpdate.ToEntity();
         this.touristSpotLogic.Update(id, touristSpot);
         var touristSpotToReturn = this.touristSpotLogic.Get(id);
         return(Ok(new TouristSpotModelOut(touristSpotToReturn)));
     }
     catch (Exception ex)
     {
         return(NotFound("There is no tourist spot with such id."));
     }
 }
Beispiel #2
0
 //[ServiceFilter(typeof(AuthorizationAttributeFilter))]
 public IActionResult Post([FromBody] TouristSpotModelIn touristSpotModel)
 {
     try
     {
         var touristSpot = touristSpotModel.ToEntity();
         this.touristSpotLogic.Add(touristSpot);
         return(CreatedAtRoute(routeName: "GetTouristSpot",
                               routeValues: new { id = touristSpotModel.Id },
                               value: new TouristSpotModelIn(touristSpot)));
     }
     catch (Exception ex)
     {
         return(BadRequest("A tourist spot with such name has been already registered."));
     }
 }