public IHttpActionResult Delete(int id) { try { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, HotelService.DeleteHotel(id)))); } catch (Exception e) { return(InternalServerError()); } }
/// <summary> /// Delete an item from the list /// </summary> /// <param name=<em>"id"</em>>id of the item to be deleted</param> // DELETE: api/Country/5 public bool Delete(int id) { if (id >= 0) { return(_HotelService.DeleteHotel(id)); } return(false); }
public IActionResult DeleteHotel(int id) { if (_hotelService.GetHotelById(id) != null) { _hotelService.DeleteHotel(id); return(Ok()); //200+data } return(NotFound()); }
public IActionResult Delete(int id) { if (_hotelService.GetHotelById(id) != null) { _hotelService.DeleteHotel(id); return(Ok()); } return(NotFound("Hotel is not found")); }
public async Task <IActionResult> DeleteHotel(int id) { if (await _hotelService.GetHotelById(id) != null) { await _hotelService.DeleteHotel(id); return(Ok()); // 200 } return(NotFound()); //404 }
public ActionResult DeleteHotel(int?id) { if (id == null) { return(View("Error")); } _hotelService.DeleteHotel(id); return(RedirectToAction("AllHotels")); }
public IActionResult Delete(int id) { var deletedHotel = _hotelService.GetHotelById(id); if (deletedHotel != null) { _hotelService.DeleteHotel(id); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> DeleteHotel(int id) { if (await _hotelService.GetHotelById(id) != null) //bana gelen otelin id si veritabanında varsa { await _hotelService.DeleteHotel(id); return(Ok()); //200 } return(NotFound()); }
public IActionResult DeleteHotel(int hotelId) { try { hotelService.DeleteHotel(hotelId); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Delete(int id) { var deletedHotel = _hotelService.GetHotel(id); if (deletedHotel == null) { return(NotFound("Hotel sa zadatim id ne postoji")); } _hotelService.DeleteHotel(id); return(Ok("Uspesno obrisano")); }
public ActionResult DeleteConfirmed(int id) { try { hotelService.DeleteHotel(id); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(View()); }
public async Task <IActionResult> DeleteConfirm(int id) { var hotel = await _hotelService.GetHotel(id); var isAuthorize = await _authorizationService.AuthorizeAsync(User, hotel, HotelOperations.Delete); if (!isAuthorize.Succeeded) { return(Forbid()); } await _hotelService.DeleteHotel(id); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(int id) { if (id <= 0) { return(BadRequest()); } else if (hotelService.GetByIdHotel(id) != null) { await hotelService.DeleteHotel(id); return(NoContent()); } else { return(BadRequest()); } }
public JsonResult HotelDelete(int id) { var result = _iHotelService.DeleteHotel(id); return(Json(result)); }
public HotelApiModule(IHotelService hotelService) : base("/api/hotel") { Get["/"] = _ => { string q = null; int p = 0; string f = null; if (Request.Query["q"] != null) { q = Request.Query["q"]; } if (Request.Query["p"] != null) { p = Request.Query["p"]; } if (Request.Query["f"]) { f = Request.Query["f"]; } return(Response.AsJson(hotelService.FindHotels(q, f != null ? f.Split(',') : new string[0], p))); }; Get["/{hotelId}"] = _ => { int hotelId = Context.Parameters["hotelId"]; return(Response.AsJson(hotelService.GetHotel(hotelId))); }; Get["/history"] = _ => { return(Response.AsJson(hotelService.GetHistory(0))); }; Post["/"] = Post["/{hotelId}"] = _ => { HotelModel model = this.Bind(); int hotelId = model.Id; if (hotelId == 0 && Context.Parameters["hotelId"] != null) { hotelId = Context.Parameters["hotelId"] ?? 0; } try { if (hotelId == 0) { hotelId = hotelService.AddHotel(model.Name, model.Description, model.ResortName, model.Image, model.Latitude, model.Longitude); } else { hotelService.UpdateHotel(hotelId, model.Name, model.Description, model.Image); } if (model.Facts != null) { hotelService.SetHotelFacts(hotelId, model.Facts); } return(Response.AsJson(new { HotelId = hotelId })); } catch (InvalidOperationException ex) { var response = Response.AsJson(new { ex.Message }); return(response.StatusCode = HttpStatusCode.NotFound); } }; Delete["/{hotelId}"] = _ => { int hotelId = Context.Parameters["hotelId"]; hotelService.DeleteHotel(hotelId); var response = new Response(); response.StatusCode = HttpStatusCode.Accepted; return(new Response()); }; }
public IActionResult OnPostAsync() { hotelService.DeleteHotel(Hotel.HotelNr); return(RedirectToPage("GetAllHotels")); }
public async Task <IActionResult> OnPostDeleteAsync(int id) { await _hotelService.DeleteHotel(id); return(RedirectToPage("/Hotels/GetAllHotels")); }
public void Delete(int id) { _hotelService.DeleteHotel(id); }
public async Task <IActionResult> DeleteHotel(int id) { await _service.DeleteHotel(id); return(Ok()); }
/// <summary> /// 删除酒店 /// </summary> /// <param name="ids">需要删除的酒店</param> public void Delete(List <string> ids) { hotelServiceImp.DeleteHotel(ids); }
public HotelApiModule(IHotelService hotelService) : base("/api/hotel") { Get["/"] = _ => { string q = null; int p = 0; string f = null; if (Request.Query["q"] != null) { q = Request.Query["q"]; } if (Request.Query["p"] != null) { p = Request.Query["p"]; } if (Request.Query["f"]) { f = Request.Query["f"]; } return Response.AsJson(hotelService.FindHotels(q, f!=null ? f.Split(',') : new string[0], p)); }; Get["/{hotelId}"] = _ => { int hotelId = Context.Parameters["hotelId"]; return Response.AsJson(hotelService.GetHotel(hotelId)); }; Get["/history"] = _ => { return Response.AsJson(hotelService.GetHistory(0)); }; Post["/"] = Post["/{hotelId}"] = _ => { HotelModel model = this.Bind(); int hotelId = model.Id; if (hotelId == 0 && Context.Parameters["hotelId"] != null) { hotelId = Context.Parameters["hotelId"] ?? 0; } try { if (hotelId == 0) hotelId = hotelService.AddHotel(model.Name, model.Description, model.ResortName, model.Image, model.Latitude, model.Longitude); else hotelService.UpdateHotel(hotelId, model.Name, model.Description, model.Image); if (model.Facts != null) { hotelService.SetHotelFacts(hotelId, model.Facts); } return Response.AsJson(new { HotelId = hotelId }); } catch (InvalidOperationException ex) { var response = Response.AsJson(new { ex.Message }); return response.StatusCode = HttpStatusCode.NotFound; } }; Delete["/{hotelId}"] = _ => { int hotelId = Context.Parameters["hotelId"]; hotelService.DeleteHotel(hotelId); var response = new Response(); response.StatusCode = HttpStatusCode.Accepted; return new Response(); }; }
public ViewResult Delete(HotelViewModel model) { _hotelService.DeleteHotel(model.Hotel); ViewData["Message"] = "Følgende informasjon er slettet fra databasen."; return(View("Delete", model)); }