Exemplo n.º 1
0
 public static Offer MapOfferDtoToEntity(OfferDto offerDto)
 {
     return new Offer()
     {
         Id = offerDto.Id,
         Value = offerDto.Value,
         Created = offerDto.Created,
         BuyerId = offerDto.Buyer.UserId,
         //PropertyId = offerDto.PropertyId
     };
 }
Exemplo n.º 2
0
        public async Task<IHttpActionResult> PostOffer(OfferDto offerDto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            offerDto.Id = Guid.NewGuid();
            offerDto.Created = DateTime.UtcNow;
            await this.offersRepository.CreateOffer(offerDto.PropertyId, Mapper.MapOfferDtoToEntity(offerDto));

            return CreatedAtRoute("DefaultApi", new { id = offerDto.Id }, offerDto);
        }
Exemplo n.º 3
0
        public async Task<IHttpActionResult> PutOffer(Guid id, OfferDto offerDto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

            await this.offersRepository.UpdateOffer(Mapper.MapOfferDtoToEntity(offerDto));
            
            return StatusCode(HttpStatusCode.NoContent);
        }