public IHttpActionResult Delete(int id)
 {
     try {
         return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, HotelService.DeleteHotel(id))));
     } catch (Exception e) {
         return(InternalServerError());
     }
 }
Example #2
0
 /// <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);
 }
Example #3
0
 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"));
 }
Example #5
0
        public async Task <IActionResult> DeleteHotel(int id)
        {
            if (await _hotelService.GetHotelById(id) != null)
            {
                await _hotelService.DeleteHotel(id);

                return(Ok());   // 200
            }
            return(NotFound()); //404
        }
Example #6
0
        public ActionResult DeleteHotel(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }

            _hotelService.DeleteHotel(id);

            return(RedirectToAction("AllHotels"));
        }
Example #7
0
        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());
        }
Example #9
0
 public IActionResult DeleteHotel(int hotelId)
 {
     try
     {
         hotelService.DeleteHotel(hotelId);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #10
0
        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"));
        }
Example #11
0
        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)));
        }
Example #13
0
        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());
            }
        }
Example #14
0
        public JsonResult HotelDelete(int id)
        {
            var result = _iHotelService.DeleteHotel(id);

            return(Json(result));
        }
Example #15
0
        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());
            };
        }
Example #16
0
 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());
        }
Example #20
0
 /// <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();
                                       };
        }
Example #22
0
 public ViewResult Delete(HotelViewModel model)
 {
     _hotelService.DeleteHotel(model.Hotel);
     ViewData["Message"] = "Følgende informasjon er slettet fra databasen.";
     return(View("Delete", model));
 }