public void SetUp() { aCategory = new Category() { Id = Guid.NewGuid(), Name = "Playa", }; categoryTouristSpot = new CategoryTouristSpot() { Category = aCategory, CategoryId = aCategory.Id, }; picture = new Picture() { Id = Guid.NewGuid(), Path = "Desktop/foto.jpg" }; lodgingPicture = new LodgingPicture() { Picture = picture, PictureId = picture.Id }; touristSpot = new TouristSpot { Id = Guid.NewGuid(), Name = "Maldonado", Description = "Departamento donde la naturaleza y la tranquilidad desborda.", ListOfCategories = new List <CategoryTouristSpot>() { categoryTouristSpot }, Image = picture }; categoryTouristSpot.TouristSpot = touristSpot; categoryTouristSpot.TouristSpotId = touristSpot.Id; lodging = new Lodging() { Id = Guid.NewGuid(), Name = "Hotel Las Cumbres", Description = "Magnifico hospedaje", QuantityOfStars = 5, Address = "Ruta 12 km 3.5", PricePerNight = 150, TouristSpot = touristSpot, Images = new List <LodgingPicture>() { lodgingPicture } }; }
public Lodging Create(Lodging lodging, Guid touristSpotId, List <string> pathOfPictures) { try { VerifyIfLodgingExist(lodging, touristSpotId); lodging.Id = Guid.NewGuid(); TouristSpot touristSpotForLodging = touristSpotManagementLogic.GetTouristSpotById(touristSpotId); lodging.TouristSpot = touristSpotForLodging; if (pathOfPictures != null) { foreach (string picturePath in pathOfPictures) { Picture pictureOfLodging = new Picture() { Path = picturePath, Id = Guid.NewGuid() }; LodgingPicture lodgingPicture = new LodgingPicture() { Lodging = lodging, LodgingId = lodging.Id, Picture = pictureOfLodging, PictureId = pictureOfLodging.Id }; lodging.Images.Add(lodgingPicture); } } lodging.VerifyFormat(); lodgingRepository.Add(lodging); return(lodging); } catch (LodgingException e) { throw new DomainBusinessLogicException(e.Message); } catch (DomainBusinessLogicException e) { throw new DomainBusinessLogicException(e.Message); } catch (ClientBusinessLogicException e) { throw new ClientBusinessLogicException(MessageExceptionBusinessLogic.ErrorCreatingLodging, e); } catch (ServerException e) { throw new ServerBusinessLogicException("No se puede crear el hospedaje debido a que ha ocurrido un error.", e); } }
public void SetUp() { region = new Region() { Id = Guid.NewGuid(), Name = Region.RegionName.Región_Centro_Sur }; aCategory = new Category() { Id = Guid.NewGuid(), Name = "Playa", }; categoryTouristSpot = new CategoryTouristSpot() { Category = aCategory, CategoryId = aCategory.Id, }; picture = new Picture() { Path = "Desktop/joaco/foto.jpg" }; listOfPicturesPath = new List <string>() { picture.Path }; touristSpot = new TouristSpot { Id = Guid.NewGuid(), Name = "Maldonado", Description = "Departamento donde la naturaleza y la tranquilidad desborda.", ListOfCategories = new List <CategoryTouristSpot>() { categoryTouristSpot }, Image = picture, Region = region }; categoryTouristSpot.TouristSpot = touristSpot; categoryTouristSpot.TouristSpotId = touristSpot.Id; lodgingPicture = new LodgingPicture() { Picture = picture, PictureId = picture.Id }; lodging = new Lodging() { Id = Guid.NewGuid(), Name = "Hotel Las Cumbres", Description = "Magnifico hospedaje", QuantityOfStars = 5, Address = "Ruta 12 km 3.5", PricePerNight = 150, TouristSpot = touristSpot, Images = new List <LodgingPicture> { lodgingPicture } }; touristSpotOfPuntaDelEste = new TouristSpot() { Id = Guid.NewGuid(), Name = "Punta del este", Description = "Donde el lujo y la naturaleza convergen, las mejores playas del Uruguay." }; lodgingConrad = new Lodging() { Id = Guid.NewGuid(), Name = "Hotel Enjoy Conrad", QuantityOfStars = 5, Address = "Ruta 12 km 3.5", PricePerNight = 1500, TouristSpot = touristSpotOfPuntaDelEste }; }
public Lodging Create(Lodging lodging, TouristSpot touristSpot, List <string> pathOfPictures) { try { Lodging lodgingObteined = lodgingRepository.GetLodgingByNameAndTouristSpot(lodging.Name, touristSpot.Id); if (lodgingObteined != null) { throw new DomainBusinessLogicException(MessageExceptionBusinessLogic.ErrorLodgingAlredyExist); } lodging.Id = Guid.NewGuid(); TouristSpot touristSpotForLodging; try { touristSpotForLodging = touristSpotManagementLogic.GetTouristSpotById(touristSpot.Id); } catch (ClientBusinessLogicException) { touristSpotForLodging = touristSpotManagementLogic.Create(touristSpot, touristSpot.Region.Id, touristSpot.ListOfCategories.ConvertAll(c => c.CategoryId)); } lodging.TouristSpot = touristSpotForLodging; if (pathOfPictures != null) { foreach (string picturePath in pathOfPictures) { Picture pictureOfLodging = new Picture() { Path = picturePath, Id = Guid.NewGuid() }; LodgingPicture lodgingPicture = new LodgingPicture() { Lodging = lodging, LodgingId = lodging.Id, Picture = pictureOfLodging, PictureId = pictureOfLodging.Id }; lodging.Images.Add(lodgingPicture); } } lodging.VerifyFormat(); lodgingRepository.Add(lodging); return(lodging); } catch (LodgingException e) { throw new DomainBusinessLogicException(e.Message); } catch (DomainBusinessLogicException e) { throw new DomainBusinessLogicException(e.Message); } catch (ClientBusinessLogicException e) { throw new ClientBusinessLogicException(MessageExceptionBusinessLogic.ErrorCreatingLodging, e); } catch (ServerException e) { throw new ServerBusinessLogicException("No se puede crear el hospedaje debido a que ha ocurrido un error.", e); } }
public void SetUp() { image = new Picture() { Id = Guid.NewGuid(), Path = "c:/MiDirectorio/Imagenes/Paisaje.png" }; lodgingPicture = new LodgingPicture() { Picture = image, PictureId = image.Id }; regionForTouristSpot = new Region() { Id = Guid.NewGuid(), Name = Region.RegionName.Región_Centro_Sur, }; category = new Category() { Id = Guid.NewGuid(), Name = "Playa" }; touristSpotAdded = new TouristSpot() { Id = Guid.NewGuid(), Name = "Maldonado", Description = "Un lugar increible", Region = regionForTouristSpot, ListOfCategories = new List <CategoryTouristSpot>() { new CategoryTouristSpot() { Category = category } } }; lodgingOfConrad = new Lodging() { Images = new List <LodgingPicture>() { lodgingPicture }, Id = Guid.NewGuid(), Name = "Hotel Enjoy Conrad", Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 100, TouristSpot = touristSpotAdded }; lodgingOfCumbres = new Lodging() { Images = new List <LodgingPicture>() { lodgingPicture }, Id = Guid.NewGuid(), Name = "Hotel Las Cumbres", Address = "Un lugar para descansar con la pareja", QuantityOfStars = 4, PricePerNight = 200, TouristSpot = touristSpotAdded }; searchOfLodgingModel = new SearchOfLodgingModelForRequest() { CheckIn = new DateTime(2020, 10, 05), CheckOut = new DateTime(2020, 10, 07), QuantityOfAdult = 1, QuantityOfChilds = 1, QuantityOfBabies = 1, TouristSpotIdSearch = touristSpotAdded.Id }; }
public void SetUp() { image = new Picture() { Id = Guid.NewGuid(), Path = "c:/MiDirectorio/Imagenes/Paisaje.png" }; lodgingPicture = new LodgingPicture() { Picture = image, PictureId = image.Id }; lodgingTouristSpotModel = new TouristSpotModelForLodgingResponseModel() { Id = Guid.NewGuid(), Name = "Punta del Este", }; reviewModelForResponse = new ReviewModelForResponse() { Description = "Muy buena", Id = Guid.NewGuid(), LastNameOfWhoComments = "Her", NameOfWhoComments = "Agustin", Score = 3 }; lodgingModelForSearchResponse = new LodgingModelForResponse() { Id = Guid.NewGuid(), Name = "Hotel las cumbres", ImagesPath = new List <string> { image.Path }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, LodgingTouristSpotModel = lodgingTouristSpotModel, ReviewsAverageScore = 4.3, ReviewsForLodging = new List <ReviewModelForResponse>() { reviewModelForResponse } }; review = new Review() { Description = "Muy buena", Id = Guid.NewGuid(), LastNameOfWhoComments = "Her", NameOfWhoComments = "Agustin", Score = 3 }; lodgingModelForResponse = new LodgingModelForResponse() { Id = Guid.NewGuid(), Name = "Hotel las cumbres", ImagesPath = new List <string> { image.Path }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, LodgingTouristSpotModel = lodgingTouristSpotModel, ReviewsAverageScore = 4.3, ReviewsForLodging = new List <ReviewModelForResponse> { reviewModelForResponse } }; lodgingModelForRequest = new LodgingModelForRequest() { Id = Guid.NewGuid(), Name = "Hotel las cumbres", Images = new List <string> { image.Path }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, TouristSpotId = lodgingTouristSpotModel.Id }; regionForTouristSpot = new Region() { Id = Guid.NewGuid(), Name = Region.RegionName.Región_Centro_Sur, }; category = new Category() { Id = Guid.NewGuid(), Name = "Playa" }; touristSpotAdded = new TouristSpot() { Id = Guid.NewGuid(), Name = "Punta del Este", Image = image, Description = "Un lugar increible", Region = regionForTouristSpot, ListOfCategories = new List <CategoryTouristSpot>() { new CategoryTouristSpot() { Category = category } } }; lodgingOfficial = new Lodging() { Id = lodgingModelForRequest.Id, Name = "Hotel las cumbres", Images = new List <LodgingPicture>() { lodgingPicture }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, TouristSpot = touristSpotAdded }; lodgingForGet = new Lodging() { Id = lodgingModelForSearchResponse.Id, Name = "Hotel las cumbres", Images = new List <LodgingPicture>() { lodgingPicture }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, TouristSpot = touristSpotAdded, ReviewsAverageScore = 4.3, Reviews = new List <Review> { review } }; }