Ejemplo n.º 1
0
        public void CreatePropertyTest()
        {
            var properties = _realStateAPIRepository.GetProperties();

            var lastProperty = properties[properties.Count - 1];

            Property property = new Property
            {
                Name         = "Property Test",
                Address      = "Test 123",
                CodeInternal = "123ABC",
                Price        = 1500,
                Views        = 0,
                Year         = 2015,
                IdOwner      = 1
            };

            _realStateAPIRepository.CreateProperty(property);
            _realStateAPIRepository.Save();

            var propertyCreated = _realStateAPIRepository.GetPropertyById(lastProperty.IdProperty + 1);

            Assert.AreEqual(property, propertyCreated);

            Assert.Pass();
        }
Ejemplo n.º 2
0
        public ActionResult <PropertyDTO> CreateProperty([FromBody] PropertyDTO propertyCreation)
        {
            try
            {
                Property property = _mapper.Map <Property>(propertyCreation);

                _realStateAPIRepository.CreateProperty(property);
                _realStateAPIRepository.Save();

                PropertyDTO propertyDTO = _mapper.Map <PropertyDTO>(property);

                return(new CreatedAtRouteResult("GetPropertyById", new { idProperty = property.IdProperty }, propertyDTO));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Ejemplo n.º 3
0
        public ActionResult <PropertyImageDTO> AddPropertyImage([FromBody] PropertyImageDTO propertyImageCreation)
        {
            PropertyImage propertyImage = _mapper.Map <PropertyImage>(propertyImageCreation);

            _realStateAPIRepository.AddPropertyImage(propertyImage);
            _realStateAPIRepository.Save();

            PropertyImageDTO propertyImageDTO = _mapper.Map <PropertyImageDTO>(propertyImage);

            return(new CreatedAtRouteResult("GetPropertyImageById", new { idPropertyImage = propertyImage.IdPropertyImage }, propertyImageDTO));
        }