Ejemplo n.º 1
0
 public static Property MapPropertyDtoToEntity(PropertyDto propertyDto)
 {
     return new Property()
     {
         Id = propertyDto.Id,
         Name = propertyDto.Name,
         Price = propertyDto.Price,
         Description = propertyDto.Description,
         Sold = propertyDto.Sold,
         OwnerId = propertyDto.Owner.UserId,
         Created = propertyDto.Created,
         Location = Mapper.MapAddressDtoToEntity(propertyDto.Location)
     };
 }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> PutProperty(Guid id, PropertyDto propertyDto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (propertyDto.Id == Guid.Empty)
            {
                propertyDto.Id = id;
            }

            await this.propertiesRepository.UpdateProperty(Mapper.MapPropertyDtoToEntity(propertyDto));

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 3
0
        public async Task<IHttpActionResult> PostProperty(PropertyDto propertyDto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            propertyDto.Id = Guid.NewGuid();
            propertyDto.Created = DateTime.UtcNow;
            await this.propertiesRepository.CreateProperty(Mapper.MapPropertyDtoToEntity(propertyDto));

            return CreatedAtRoute("DefaultApi", new { id = propertyDto.Id }, propertyDto);
        }