Ejemplo n.º 1
0
 public TouristSpot UpdateTouristSpot(TouristSpot touristSpot)
 {
     try
     {
         TouristSpot touristSpotDb = touristSpotRepository.Get(touristSpot.Id);
         touristSpotDb.UpdateAttributes(touristSpot);
         touristSpotDb.VerifyFormat();
         touristSpotRepository.Update(touristSpotDb);
         return(touristSpotDb);
     }
     catch (ServerException e)
     {
         throw new ServerBusinessLogicException("No se puede actualizar el punto turistico.", e);
     }
 }
Ejemplo n.º 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);
     }
 }