示例#1
0
 public IActionResult Put(Guid id, [FromBody] LodgingModelForRequest lodgingModel)
 {
     try
     {
         Lodging lodging = lodgingManagement.UpdateLodging(id, LodgingModelForRequest.ToEntity(lodgingModel));
         return(CreatedAtRoute("lodging", new { id = lodging.Id }, LodgingModelForResponse.ToModel(lodging)));
     }
     catch (DomainBusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
示例#2
0
 public IActionResult Post([FromBody] LodgingModelForRequest lodgingModel)
 {
     try
     {
         Lodging lodging = lodgingManagement.Create(LodgingModelForRequest.ToEntity(lodgingModel), lodgingModel.TouristSpotId, lodgingModel.Images);
         return(CreatedAtRoute("lodging", new { id = lodging.Id }, LodgingModelForSearchResponse.ToModel(lodging)));
     }
     catch (DomainBusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }