public void SetUp()
        {
            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",
                Description      = "Un lugar increible",
                Region           = regionForTouristSpot,
                ListOfCategories = new List <CategoryTouristSpot>()
                {
                    new CategoryTouristSpot()
                    {
                        Category = category
                    }
                },
                Image = new Picture()
                {
                    Path = "Desktop/joaco.jpg"
                }
            };

            touristSpotRequestModel = new TouristSpotForRequestModel()
            {
                Id                 = touristSpotAdded.Id,
                Name               = "Punta del Este",
                Description        = "Un lugar increible",
                RegionId           = regionForTouristSpot.Id,
                ListOfCategoriesId = new List <Guid>()
                {
                    category.Id
                },
                ImagePath = "Desktop/joaco.jpg"
            };

            touristSpotResponseModel = new TouristSpotForResponseModel
            {
                Id                    = touristSpotAdded.Id,
                Name                  = "Punta del Este",
                Description           = "Un lugar increible",
                RegionModel           = RegionForResponseModel.ToModel(regionForTouristSpot),
                ListOfCategoriesModel = new List <CategoryModel>()
                {
                    CategoryModel.ToModel(category)
                },
                ImagePath = "Desktop/joaco.jpg"
            };
        }
 public IActionResult Get()
 {
     try
     {
         List <TouristSpot> allTouristSpots = touristSpotManagement.GetAllTouristSpot();
         return(Ok(TouristSpotForResponseModel.ToModel(allTouristSpots)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
 public IActionResult Get(Guid id)
 {
     try
     {
         TouristSpot touristSpot = touristSpotManagement.GetTouristSpotById(id);
         return(Ok(TouristSpotForResponseModel.ToModel(touristSpot)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
 public IActionResult GetTouristSpotsByCategoriesAndRegionId([FromQuery] Guid[] categoriesId, [FromQuery] Guid regionId)
 {
     try
     {
         List <TouristSpot> touristSpotsByRegionAndCategories = touristSpotManagement.
                                                                GetTouristSpotsByCategoriesAndRegion(categoriesId.ToList(), regionId);
         return(Ok(TouristSpotForResponseModel.ToModel(touristSpotsByRegionAndCategories)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
        public void CreateTouristSpotNotEqualsIdTest()
        {
            TouristSpotForRequestModel touristSpotRequestModel = new TouristSpotForRequestModel()
            {
                Id                 = touristSpotAdded.Id,
                Name               = "Punta del Este",
                Description        = "Un lugar increible",
                RegionId           = regionForTouristSpot.Id,
                ImagePath          = "Desktop/joaco.jpg",
                ListOfCategoriesId = new List <Guid>()
                {
                    category.Id
                }
            };
            var touristSpotMock = new Mock <ITouristSpotManagement>(MockBehavior.Strict);

            touristSpotMock.Setup(m => m.Create(It.IsAny <TouristSpot>(), It.IsAny <Guid>(), It.IsAny <List <Guid> >())).Returns(touristSpotAdded);
            TouristSpotController touristSpotController = new TouristSpotController(touristSpotMock.Object);
            var result        = touristSpotController.Post(touristSpotRequestModel);
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as TouristSpotForResponseModel;

            touristSpotMock.VerifyAll();

            TouristSpotForResponseModel touristSpotResponseModel = new TouristSpotForResponseModel()
            {
                Id                    = Guid.NewGuid(),
                Name                  = "Punta del ",
                Description           = "Un lugar increible",
                RegionModel           = RegionForResponseModel.ToModel(regionForTouristSpot),
                ListOfCategoriesModel = new List <CategoryModel>()
                {
                    CategoryModel.ToModel(category)
                }
            };

            Assert.AreNotEqual(touristSpotRequestModel, model);
        }
 public IActionResult Post([FromBody] TouristSpotForRequestModel aTouristSpot)
 {
     try
     {
         TouristSpot touristSpotAdded = touristSpotManagement.Create(TouristSpotForRequestModel.ToEntity(aTouristSpot), aTouristSpot.RegionId, aTouristSpot.ListOfCategoriesId);
         return(CreatedAtRoute("touristSpot", new { id = touristSpotAdded.Id }, TouristSpotForResponseModel.ToModel(touristSpotAdded)));
     }
     catch (DomainBusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }