public async Task <IActionResult> PostHotel([FromBody] Hotel.Entities.Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("GetHotelById", new { id = createdHotel.Id }, createdHotel)); //dönen response un header kısmında oluşturulan otelin hangi url de oldugu da belirtilir }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { // [ApiController] olmasaydı Model.IsValid ile test etmemiz gerekirdi var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createdHotel.Id }, createdHotel));//201+data }
public IActionResult OnPost(Hotel hotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } hotelService.CreateHotel(hotel); return(RedirectToPage("GetAllHotels")); }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { if (ModelState.IsValid)//[ApiController tanımlı olduğu için aslında buna gerek yok] { var createHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createHotel.Id }, createHotel)); //201 + data } return(BadRequest(ModelState)); //400 + validation data }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { if (ModelState.IsValid) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createdHotel.Id }, createdHotel)); // response code : 201 + data } return(BadRequest(ModelState)); // response code : 400 + validation errors" }
public async Task <IActionResult> Post([FromBody] Hotel hotel) { if (ModelState.IsValid) { var hotelPost = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = hotelPost.Id }, hotelPost)); //Dönen kısmın header kısmında oluşturulan otelın hangi url de oldugunu belirtmek icin CreatedAtAction kullandık } return(BadRequest(ModelState)); //400+ validation error }
public IActionResult Post([FromBody] Hotel hotel) { //if (ModelState.IsValid) benim yukarıdaki ApiController diye bir route var. Bu hotel.cs de reuqired olanları orada kontrol ediyor. Dolayısıyla eğer apicontroller olmasaydi modelstate.isvalid kullanırdır ama olduğu için kullanmaya gerenk yok. //{ var createHotel = _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createHotel.Id }, createHotel)); //201 + data //} // return BadRequest(ModelState); //400 +validation errors }
public IActionResult Create(Hotel hotel) { ViewBag.User = GetUser(); ViewBag.Cities = cityService.GetAllCities(); var creationResult = hotelService.CreateHotel(hotel); if (creationResult != null) { } return(RedirectToAction("hotels", "settings")); }
public async Task <IActionResult> Post([FromBody] Hotel hotel) { if (ModelState.IsValid) { var post = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { Id = post.id }, post)); //201 } return(BadRequest(ModelState)); }
public ActionResult CreateHotel(Hotel model) { if (ModelState.IsValid) { _hotelService.CreateHotel(model); return(RedirectToAction("Details", new { id = model.Id })); } return(View(model)); }
public async Task <IActionResult> Create(HotelViewModel hotelVM) { if (ModelState.IsValid) { hotelVM.Hotel.OwnerID = _identityService.Get(User).Id; hotelVM.Hotel.ImageUrl = hotelVM.ImageUrl.FileName; await _hotelService.CreateHotel(hotelVM.Hotel); await UploadFileImg(hotelVM.ImageUrl); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> CreateHotel([FromBody] HotelDto hotelDto) { if (!ModelState.IsValid) { return(BadRequest()); } var response = await _hotelService.CreateHotel(hotelDto); if (response.Error != null) { return(BadRequest(response)); } return(Ok(response)); }
public ActionResult Create(HotelViewModel hotelViewModel) { try { if (ModelState.IsValid) { HotelDTO newHotel = new HotelDTO() { Name = hotelViewModel.Name, Address = hotelViewModel.Address }; hotelService.CreateHotel(newHotel); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log.) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } return(View(hotelViewModel)); }
public IActionResult CreateHotel([FromBody] Hotel hotel) { var createHotel = _hotelService.CreateHotel(hotel); return(CreatedAtAction("GET", new { id = createHotel.Id, createHotel })); //201 + hotel data }
public async Task <HotelDTO> RegisterHotel([FromBody] HotelCreateDTO hotelCreateDTO) { return(await hotelService.CreateHotel(hotelCreateDTO)); }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(Ok(createdHotel)); }
public Hotel Post([FromBody] Hotel hotel) { return(_hotelService.CreateHotel(hotel)); }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createdHotel.Id }, createdHotel)); }
public IActionResult Post([FromBody] Hotel hotel) { var createdHotel = _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", new { id = createdHotel.Id }, createdHotel));//201 + data }
public IHttpActionResult CreateHotel([FromBody] Hotel hotel) { return(Ok(_hotelService.CreateHotel(hotel))); }
/// <summary> /// 创建酒店 /// </summary> /// <param name="HotelDataObject"></param> /// <returns></returns> public string Post(List <HotelDataObject> HotelDataObject) { var hotels = hotelServiceImp.CreateHotel(HotelDataObject); return(JsonConvert.SerializeObject(hotels)); }
public async Task <IActionResult> Post([FromBody] Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction("Get", routeValues: new { id = createdHotel.Id }, createdHotel)); // 201+data }
public async Task <IActionResult> CreateHotel([FromBody] Hotel hotel) { var createdHotel = await _hotelService.CreateHotel(hotel); return(CreatedAtAction(nameof(GetHotelById), new { id = createdHotel.Id }, createdHotel)); //201 + data }
public async Task <IActionResult> OnPostAsync() { await _hotelService.CreateHotel(Hotel); return(RedirectToPage("/Hotels/GetAllHotels")); }