public IActionResult Get(Guid id)
 {
     try
     {
         Region region = regionManagement.GetById(id);
         return(Ok(RegionForResponseModel.ToModel(region)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Beispiel #2
0
 public TouristSpot Create(TouristSpot touristSpot, Guid regionId, List <Guid> categoriesId)
 {
     try
     {
         VerifyIfTouristSpotExist(touristSpot);
         touristSpot.Id = Guid.NewGuid();
         Region regionForTouristSpot = regionManagementLogic.GetById(regionId);
         touristSpot.Region = regionForTouristSpot;
         List <Category> listOfCategoriesToAdd = categoryManagementLogic.GetAssociatedCategories(categoriesId);
         foreach (Category category in listOfCategoriesToAdd)
         {
             CategoryTouristSpot categoryTouristSpot = new CategoryTouristSpot()
             {
                 TouristSpot   = touristSpot,
                 TouristSpotId = touristSpot.Id,
                 Category      = category,
                 CategoryId    = category.Id
             };
             touristSpot.ListOfCategories.Add(categoryTouristSpot);
         }
         touristSpot.VerifyFormat();
         touristSpotRepository.Add(touristSpot);
         return(touristSpot);
     }
     catch (TouristSpotException e)
     {
         throw new DomainBusinessLogicException(e.Message);
     }
     catch (DomainBusinessLogicException e)
     {
         throw new DomainBusinessLogicException(e.Message);
     }
     catch (ClientBusinessLogicException e)
     {
         throw new ClientBusinessLogicException(MessageExceptionBusinessLogic.ErrorCreatingTouristSpot, e);
     }
     catch (ServerException e)
     {
         throw new ServerBusinessLogicException("No se puede crear el punto turistico debido a que no es valido.", e);
     }
 }