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); }
public void ValidTouristSpotIsValid() { Assert.IsFalse(TouristSpot.Validate().HasErrors()); }