public IHttpActionResult Posthotel(hotel hotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.hotel.Add(hotel); try { db.SaveChanges(); } catch (DbUpdateException) { if (hotelExists(hotel.precio)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = hotel.precio }, hotel)); }
public review(hotel thisHotel, customer thisCust, double rating, string comment) { comment = commaSwitch(comment)[0]; SqlCommand newCommand = new SqlCommand("INSERT INTO Reviews (HotelId, CustomerId, StarRating, Comments) VALUES (" + thisHotel.returnId + ", " + thisCust.returnId + ", " + rating + ", '" + comment + "')", dbConnect); lock (theLock) { dbConnect.Open(); newCommand.ExecuteNonQuery(); dbConnect.Close(); } SqlCommand getCommand = new SqlCommand("SELECT MAX(Id) FROM Reviews", dbConnect); lock (theLock) { dbConnect.Open(); SqlDataReader read = getCommand.ExecuteReader(); if (read.Read()) { id = Convert.ToInt32(read[0]); } dbConnect.Close(); } this.thisHotel = thisHotel; this.thisCust = thisCust; this.rating = rating; this.comment = comment; }
public ActionResult Room_Booking(hotel hotel) { using (SqlConnection con = new SqlConnection(connectionstring)) { con.Open(); //string filepath = Path.GetFileName(image1.FileName); //string savedfilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(image1.FileName)); //image1.SaveAs(Server.MapPath("~/Desktop/Images/" + filepath)); string query = "insert into hotel(avaliablerooms,checkindate,checkoutdate) values (@avaliablerooms,@checkindate,@checkoutdate)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@avaliablerooms", hotel.avaliablerooms); cmd.Parameters.AddWithValue("@checkindate", hotel.checkindate); cmd.Parameters.AddWithValue("@checkoutdate", hotel.checkoutdate); // //string fileName = Path.GetFileNameWithoutExtension(citymodel.ImageFile.FileName); //string extension = Path.GetExtension(citymodel.ImageFile.FileName); //fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; //citymodel.image = "~/Image/" + fileName; //fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); //citymodel.ImageFile.SaveAs(fileName); //using (hotelEntities2 db = new hotelEntities2()) //{ // db.Cities.Add(citymodel); // db.SaveChanges(); //} cmd.ExecuteNonQuery(); con.Close(); } return(RedirectToAction("Index")); }
// GET: hotels/Delete/5 public ActionResult Delete(int?id) { string message = "Deseja verificar se existem quartos atrelados a esse hotel?"; string caption = "Atenção!"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); if (result == DialogResult.Yes) { return(Redirect("/quarto_hotel/Index")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hotel hotel = db.hotel.Find(id); if (hotel == null) { return(HttpNotFound()); } return(View(hotel)); } }
public ActionResult Eliminar(int id) { using (hotelesEntidad db = new hotelesEntidad()) { if (!ModelState.IsValid) { return(View()); } try { hotel hotel = db.hotel.Find(id); db.hotel.Remove(hotel); db.SaveChanges(); return(RedirectToAction("Inicio")); } catch (Exception e) { TempData["Mensaje"] = new Mensajes() { Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al eliminar el hotel." }; return(View()); } } }
public ActionResult Editar(hotel h) { using (hotelesEntidad db = new hotelesEntidad()) { List <categoria> categorias = db.categoria.ToList(); ViewData["listaCategoria"] = categorias; if (!ModelState.IsValid) { return(View()); } try { hotel hotel = db.hotel.Find(h.id); hotel.nombre = h.nombre; hotel.telefono = h.telefono; hotel.fecha_construccion = h.fecha_construccion; hotel.direccion = h.direccion; hotel.categoria_id = h.categoria_id; db.SaveChanges(); TempData["Mensaje"] = new Mensajes() { Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "El hotel fue actualizado." }; return(RedirectToAction("Inicio")); } catch (Exception e) { TempData["Mensaje"] = new Mensajes() { Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar el hotel." }; return(View()); } } }
public ActionResult Agregar(hotel h) { using (hotelesEntidad db = new hotelesEntidad()) { List <categoria> categorias = db.categoria.ToList(); ViewData["listaCategoria"] = categorias; if (!ModelState.IsValid) { return(View()); } try { db.hotel.Add(h); db.SaveChanges(); TempData["Mensaje"] = new Mensajes() { Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "El hotel fue agregado satisfactoriamente." }; return(RedirectToAction("Inicio")); } catch (Exception e) { TempData["Mensaje"] = new Mensajes() { Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar el hotel." }; return(View()); } } }
public ActionResult AddHotel(hotel hotel, HttpPostedFileBase image_url, HttpPostedFileBase detail_header_image_url, HttpPostedFileBase more_imformation_image_url) { hotel.image_url = "/Content/img/hotel/hotel_image_url_" + hotel.id; hotel.detail_header_image_url = "/Content/img/hotel/hotel_detail_header_image_url_" + hotel.id; hotel.more_imformation_image_url = "/Content/img/hotel/hotel_more_imformation_image_url_" + hotel.id; context.hotels.Add(hotel); context.SaveChanges(); int value = int.Parse(context.hotels.OrderByDescending(p => p.id).Select(r => r.id).First().ToString()); string extention1 = Path.GetExtension(image_url.FileName); string extention2 = Path.GetExtension(detail_header_image_url.FileName); string extention3 = Path.GetExtension(more_imformation_image_url.FileName); hotel.image_url = "/Content/img/hotel/hotel_image_url_" + value + "." + extention1; hotel.detail_header_image_url = "/Content/img/hotel/hotel_detail_header_image_url_" + value + "." + extention2; hotel.more_imformation_image_url = "/Content/img/hotel/hotel_more_imformation_image_url_" + value + "." + extention3; context.SaveChanges(); var path = Path.Combine(Server.MapPath("/Content/img/hotel"), "hotel_image_url_" + value + "." + extention1); var path2 = Path.Combine(Server.MapPath("/Content/img/hotel"), "hotel_detail_header_image_url_" + value + "." + extention2); var path3 = Path.Combine(Server.MapPath("/Content/img/hotel"), "hotel_more_imformation_image_url_" + value + "." + extention3); image_url.SaveAs(path); detail_header_image_url.SaveAs(path2); more_imformation_image_url.SaveAs(path3); return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); }
public void deleteHotelById(int id) { hotel p = ut.HotelRepository.GetById(id); ut.HotelRepository.Delete(p); ut.commit(); }
public IHttpActionResult Puthotel(int id, hotel hotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hotel.precio) { return(BadRequest()); } db.Entry(hotel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!hotelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public room(byte[] pic, double askedPrice, string name, hotel thisHotel, int quantity) { string[] newName = commaSwitch(name); name = newName[0]; //Reassign parameter SqlCommand newCommand = new SqlCommand("INSERT INTO Rooms (Picture, AskedPrice, Name, HotelId, Quantity) VALUES (@value, " + askedPrice + ", '" + name + "', " + thisHotel.returnId + ", " + quantity + ")", dbConnect); SqlParameter param = new SqlParameter("@value", System.Data.SqlDbType.VarBinary); newCommand.Parameters.Add(param); param.Value = pic; lock (theLock) { dbConnect.Open(); newCommand.ExecuteNonQuery(); dbConnect.Close(); } newCommand = new SqlCommand("SELECT MAX(Id) FROM Rooms", dbConnect); SqlDataReader read; lock (theLock) { dbConnect.Open(); read = newCommand.ExecuteReader(); if (read.Read()) { id = Convert.ToInt32(read[0]); } dbConnect.Close(); } this.askedPrice = askedPrice; this.name = name; this.quantity = quantity; this.thisHotel = thisHotel; }
protected void findHotelLbl_Click(object sender, EventArgs e) { if (Customer.Hotel == null) { Customer.CheckIn = DateTime.Parse(checkInDate.Text); Customer.CheckOut = DateTime.Parse(checkOutDate.Text); hotel selectedHotel = new hotel(); foreach (hotel possibleHotel in hotels) { System.Diagnostics.Debug.WriteLine("Hotel: " + possibleHotel.HotelName + "\n Selected hotel: " + hotelSelectDdl.SelectedValue); if (possibleHotel.HotelName == hotelSelectDdl.SelectedValue) { selectedHotel = possibleHotel; System.Diagnostics.Debug.WriteLine("found hotel"); break; } } Customer.Hotel = selectedHotel; Customer.CheckIn = DateTime.Parse(checkInDate.Text); Customer.CheckOut = DateTime.Parse(checkOutDate.Text); } Customer.NumberOfRooms = int.Parse(roomOptionsDdl.SelectedValue); Response.Redirect("RoomSelect.aspx"); }
/// <summary> /// Create a new offer to insert into the offers table /// </summary> /// <param name="thisHotel">Hotel that this offer is directed towards</param> /// <param name="thisRoom">Room that this offer was made on</param> /// <param name="thisCustomer">Customer that sent this offer</param> /// <param name="num">Number of rooms in the offer</param> /// <param name="start">Start date that this offer would take effect</param> /// <param name="end">End date for this offer</param> /// <param name="perDay">Offered price per day, per room</param> public offer(hotel thisHotel, room thisRoom, customer thisCustomer, int num, DateTime start, DateTime end, double perDay) { totalValue = (perDay * num) * (end - start).TotalDays; SqlCommand newCommand = new SqlCommand("INSERT INTO Offers (HotelId, RoomId, CustomerId, NumberOfRooms, StartDate, EndDate, DailyOffer, TotalOffer, Accepted) VALUES (" + thisHotel.returnId + ", " + thisRoom.getId + ", " + thisCustomer.returnId + ", " + num + ", @sValue, @eValue, " + perDay + ", " + totalValue + ", 0)", dbConnect); newCommand.Parameters.AddWithValue("@sValue", start); newCommand.Parameters.AddWithValue("@eValue", end); lock (theLock) { dbConnect.Open(); newCommand.ExecuteNonQuery(); dbConnect.Close(); } SqlCommand getCommand = new SqlCommand("SELECT MAX(Id) FROM Offers", dbConnect); lock (theLock) { dbConnect.Open(); SqlDataReader read = getCommand.ExecuteReader(); if (read.Read()) { id = Convert.ToInt32(read[0]); } dbConnect.Close(); } this.thisHotel = thisHotel; this.thisRoom = thisRoom; this.thisCustomer = thisCustomer; numRooms = num; this.start = start; this.end = end; Offered_Price_Per_Day = perDay; accepted = state.NOTHING; }
protected void sbmtBTN_Click(object sender, EventArgs e) { if (allFilled) { hotel newHot = hotel.add(usernameTXT.Text, passTXT.Text, hnameTXT.Text, addTXT.Text, cityTXT.Text, stDRP.Text, phoneTXT.Text, Convert.ToInt32(zipTXT.Text)); if (newHot == null /*Returns null if username already exists in the database*/) { errorTXT.Visible = true; errorTXT.Text = "Username already exists"; } else { if (Response.IsClientConnected) { Response.Redirect("~//LoginFormHot.aspx", true); } else { errorTXT.Visible = true; errorTXT.Text = "Lost Connection"; Response.End(); } } } else { errorTXT.Visible = true; errorTXT.Text = "Please fill in all fields!"; } }
public ActionResult Create(hotel hotel, HttpPostedFileBase[] tourism_photo) { string h_id = db.Database.SqlQuery <string>("Select dbo.GethotelId()").FirstOrDefault(); hotel.hotel_id = h_id; hotel.page_status = false; //圖片 string fileName = ""; for (int i = 0; i < tourism_photo.Length; i++) { HttpPostedFileBase f = tourism_photo[i]; if (f != null) { if (f.ContentLength > 0) { string t = tourism_photo[i].FileName; fileName = hotel.hotel_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + (i + 1).ToString() + Path.GetExtension(t); f.SaveAs(Server.MapPath("~/images/hotel/" + fileName)); tourism_photo tp = new tourism_photo(); tp.tourism_photo1 = fileName; tp.tourism_id = hotel.hotel_id; db.tourism_photo.Add(tp); } } } db.hotel.Add(hotel); db.SaveChanges(); return(RedirectToAction("Index", new { page = Session["pg"] })); }
public async Task <IActionResult> Edit(int id, [Bind("id,name,AverageRoomRate,Restaurant24Hour,buffet")] hotel hotel) { if (id != hotel.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hotel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!hotelExists(hotel.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(hotel)); }
private void serializeToModel(ref hotel hotel) { hotel.name = Request.Form["name"]; if (Request.Form["tour_id"] == "") { hotel.tour_id = null; } else { hotel.tour_id = int.Parse(Request.Form["tour_id"]); } hotel.city_id = int.Parse(Request.Form["city_id"]); hotel.address = Request.Form["address"]; hotel.stars_number = int.Parse(Request.Form["stars_number"]); if (Request.Form["distance_to_beach"] == "") { hotel.distance_to_beach = null; } else { hotel.distance_to_beach = int.Parse(Request.Form["distance_to_beach"]); } if (Request.Form["food_id"] == "") { hotel.food_id = null; } else { hotel.food_id = int.Parse(Request.Form["food_id"]); } }
public IHttpActionResult PutRoom(int id, hotel room) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != room.hotelId) { return(BadRequest()); } db.Edit(room); // db.Entry(room).State = EntityState.Modified; try { db.Save(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static public bool Actualizar(hotel hote) { bool exito = true; try { using (var data = new ViajaMasEntities()) { hotel actual = data.hotel.Where(x => x.id_hotel == hote.id_hotel).FirstOrDefault(); actual.id_empresa = hote.id_empresa; actual.nombre_hotel = hote.nombre_hotel; actual.num_estrellas = hote.num_estrellas; actual.direccion = hote.direccion; actual.num_cuartos = hote.num_cuartos; actual.estado = hote.estado; data.SaveChanges(); } } catch { exito = false; } return(exito); }
/// <summary> /// Add a new hotel to the database /// </summary> /// <param name="username">Username of user</param> /// <param name="password">Password of user</param> /// <param name="name">Name of hotel</param> /// <param name="address">Address of hotel</param> /// <param name="city">City where hotel is located</param> /// <param name="state">State where hotel is located</param> /// <param name="phone">Phone # of hotel</param> /// <returns>New hotel object</returns> public static hotel add(string username, string password, string name, string address, string city, string state, string phone, int zip) { hotel newHot = new hotel(); if (newHot.addUser(username, password)) { string[] param = commaSwitch(name, address, city); name = param[0]; //Reassign parameters address = param[1]; city = param[2]; SqlCommand newCommand = new SqlCommand("INSERT INTO Hotel (Id, Name, Address, City, State, Phone, Zip) VALUES (" + newHot.id + ", '" + name + "', '" + address + "', '" + city + "', '" + state + "', '" + phone + "', " + zip + ")", newHot.dbConnect); lock (theLock) { newHot.dbConnect.Open(); newCommand.ExecuteNonQuery(); newHot.dbConnect.Close(); } newHot.retrieve(); return(newHot); } else { return(null); } }
public ActionResult Create(hotel hotel, HttpPostedFileBase tourism_photo) { string h_id = db.Database.SqlQuery <string>("Select dbo.GethotelId()").FirstOrDefault(); hotel.hotel_id = h_id; string fileName = ""; if (tourism_photo != null) { if (tourism_photo.ContentLength > 0) { fileName = System.IO.Path.GetFileName(tourism_photo.FileName); tourism_photo.SaveAs(Server.MapPath("~/images/hotel/" + fileName)); } } tourism_photo tp = new tourism_photo(); tp.tourism_photo1 = fileName; tp.tourism_id = hotel.hotel_id; db.hotels.Add(hotel); db.tourism_photo.Add(tp); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(HotelViewModel fvm, HttpPostedFileBase Image) { if (ModelState.IsValid) { Image = Request.Files["Image"]; } MemoryStream target = new MemoryStream(); Image.InputStream.CopyTo(target); byte[] trtr; trtr = target.ToArray(); hotel h = new hotel() { name = fvm.name, adresse = fvm.adresse, description = fvm.description, longitude = fvm.longitude, latitude = fvm.latitude, pic = trtr, star = fvm.star, roomNumber = fvm.roomNumber }; a.addHotel(h); return(RedirectToAction("Index")); }
public ActionResult Create(HotelViewModel fvm, HttpPostedFileBase Image) { // if (!ModelState.IsValid || Image == null || Image.ContentLength == 0) // { // return RedirectToAction("Create"); // } Image = Request.Files["Image"]; MemoryStream target = new MemoryStream(); Image.InputStream.CopyTo(target); byte[] trtr; trtr = target.ToArray(); hotel h = new hotel() { name = fvm.name, adresse = fvm.adresse, description = fvm.description, longitude = fvm.longitude, latitude = fvm.latitude, pic = trtr, star = fvm.star, roomNumber = fvm.roomNumber }; a.addHotel(h); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { hotel hotel = db.hotel.Find(id); db.hotel.Remove(hotel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(hotel hotel) { hs.Add(hotel); hs.Commit(); return(RedirectToAction("Index")); }
public void DeleteHotel(int id) { using (HotelmanagementEntities db = new HotelmanagementEntities()) { hotel h = db.hotels.Where(p => p.hotelid == id).FirstOrDefault(); db.Entry(h).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
public ActionResult AddHotel(hotel hotel) { hotel.image_url = "/Content/img/Group 68.png"; hotel.detail_header_image_url = "/Content/img/hotel-detail.jpg"; hotel.more_imformation_image_url = "/Content/img/Group 71.png"; client.AddHotel_BE(JsonConvert.SerializeObject(hotel)); //context.hotels.Add(hotel); //context.SaveChanges(); return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); }
private void button1_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtIdentificador.Text); int precio = Convert.ToInt32(txtPrecio.Text); MessageBox.Show("Se ha insertado el registro correctamente."); hotel hotel = new hotel(); hotel.hotelNe(id, precio); }
protected void cBTN_Click(object sender, EventArgs e) { cust = Session["Review Customer"] as customer; hot = Session["Review Hotel"] as hotel; hot.addReview(Convert.ToDouble(starBTN.SelectedValue), comTXT.Text, cust); Session["Hotel"] = hot; Session["Review Customer"] = null; Session["Review Hotel"] = null; Response.Redirect("~//HotPGE.aspx"); }
public ActionResult Edit([Bind(Include = "id,nome,tipo,id_cidade")] hotel hotel) { if (ModelState.IsValid) { db.Entry(hotel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_cidade = new SelectList(db.cidade, "id", "nome", hotel.id_cidade); return(View(hotel)); }
public HotelBook(hotel h) { InitializeComponent(); this.selectedHotel = h; tb_Naam.Text = h.name; tb_Ster.Text = h.stars + ""; foreach (roomType rt in h.roomTypes) cb_Kamertypen.Items.Add(rt.name); }