Ejemplo n.º 1
0
 public void Add(TouristSpot newEntity)
 {
     if (newEntity.Validate())
     {
         try
         {
             this.touristSpotRepository.Add(newEntity);
         }
         catch (RepeatedObjectException ex)
         {
             throw new RepeatedObjectException();
         }
     }
 }
        private TouristSpot TouristSpotFromParsedModel(LodgingParsed lodgingParsed)
        {
            var touristSpot = TouristSpotRepository.GetFirst(x => x.Name == lodgingParsed.TouristSpot.Name);

            if (touristSpot == null)
            {
                touristSpot = new TouristSpot
                {
                    Name        = lodgingParsed.TouristSpot.Name,
                    Description = lodgingParsed.Description,
                    RegionId    = lodgingParsed.TouristSpot.RegionId
                };

                if (!touristSpot.IsValid("Image"))
                {
                    throw new EntityNotValidException(touristSpot.Validate("Image"));
                }

                TouristSpotRepository.Add(touristSpot);
                TouristSpotRepository.Save();
            }

            return(touristSpot);
        }
Ejemplo n.º 3
0
 public void ValidTouristSpotIsValid()
 {
     Assert.IsFalse(TouristSpot.Validate().HasErrors());
 }