// POST: api/Hotel
        //can post single hotel
        public HttpResponseMessage Post([FromBody] Hotel hotel)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(_hotelManager.CreateHotel(hotel));
            return(response);
        }
Ejemplo n.º 2
0
        // POST: api/hotels
        public IHttpActionResult Add([FromBody] Models.Hotel hotel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Data is not valid."));
            }

            return(Ok(_hotelManager.CreateHotel(hotel)));
        }
Ejemplo n.º 3
0
 public async Task<IActionResult> Create([Bind("ID,Name,StreetAddress,City,State,Phone")] Hotel hotel)
 {
     if (ModelState.IsValid)
     {
         await _context.CreateHotel(hotel);
         return RedirectToAction(nameof(Index));
     }
     return View(hotel);
 }
        public async Task <IActionResult> PostHotel([FromBody] Hotel hotel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _hotel.CreateHotel(hotel);

            return(CreatedAtAction("GetHotel", new { id = hotel.ID }, hotel));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("ID,Name,Address,Phone")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                //_context.Add(hotel);
                //await _context.SaveChangesAsync();
                await _context.CreateHotel(hotel);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ID,Name,Address,Phone")] Hotel hotel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _context.CreateHotel(hotel);

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(hotel));
            }
            catch (Exception)
            {
                return(Redirect("https://http.cat/500"));
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult <Hotel> > PostHotel(Hotel hotel)
        {
            var result = await _hotels.CreateHotel(hotel);

            return(CreatedAtAction("GetHotel", new { id = result.ID }, result));
        }
Ejemplo n.º 8
0
 public IHttpActionResult PostCreateHotel([FromBody] Hotel model)
 {
     return(Ok(_hotelManager.CreateHotel(model)));
 }
        public async Task <ActionResult <Hotel> > PostHotel(Hotel hotel)
        {
            var result = await _context.CreateHotel(hotel);

            return(CreatedAtAction("GetHotel", new { id = hotel.ID }, hotel));
        }
        public async Task <ActionResult <HotelDto> > PostHotel(HotelDto hotelDto)
        {
            await _hotel.CreateHotel(hotelDto);

            return(CreatedAtAction("GetHotel", new { id = hotelDto.Id }, hotelDto));
        }
        public IHttpActionResult Post(Hotel hotel)
        {
            var response = _hotelmanager.CreateHotel(hotel);

            return(Ok(response));
        }