public static Hotel MapAsNewEntity(this CreateHotelRequestModel model)
 {
     return(new Hotel
     {
         Name = model.Name,
         City = model.City
     });
 }
Ejemplo n.º 2
0
        public async Task <ActionResult <Hotel> > Post(CreateHotelRequestModel model)
        {
            var entity = model.MapAsNewEntity();

            this.context.Hotels.Add(entity);

            await this.context.SaveChangesAsync();

            return(this.CreatedAtAction("Get", new { id = entity.Id }, entity.MapAsModel()));
        }