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 }; }
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); }
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); }