Ejemplo n.º 1
0
        public IActionResult Post([FromBody] SearchOfLodgingModelForRequest model)
        {
            try
            {
                List <Lodging> lodgingsForTouristSpotSearched = lodgingManagement.GetAvailableLodgingsByTouristSpot(model.TouristSpotIdSearch);
                model.VerifyFormat();
                LodgingForSearchModel lodgingForSearchModel = new LodgingForSearchModel()
                {
                    CheckIn         = model.CheckIn,
                    CheckOut        = model.CheckOut,
                    QuantityOfGuest = new int[4] {
                        model.QuantityOfAdult, model.QuantityOfChilds, model.QuantityOfBabies, model.QuantityOfRetireds
                    }
                };
                return(Ok(lodgingForSearchModel.ToModel(lodgingsForTouristSpotSearched)));
            }
            catch (SearchException e)
            {
                return(BadRequest(e.Message));
            }
            catch (ClientBusinessLogicException e)
            {
                return(NotFound(e.Message));
            }

            catch (ServerBusinessLogicException e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
        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
            };
        }