public IHttpActionResult PutRoom(int id, Room room) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != room.Room_No) { return(BadRequest()); } db.Entry(room).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutBooking(int id, Booking booking) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != booking.Booking_id) { return(BadRequest()); } db.Entry(booking).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public string AddBooking(BookingModel model) { string result = string.Empty; using (HotelDBContext _hotelEntities = new HotelDBContext()) { try { Booking bookingTbl = new Booking(); bookingTbl.InvoiceNumber = model.InvoiceNumber; bookingTbl.HotelId = model.HotelId; bookingTbl.RoomId = model.RoomId; bookingTbl.FromDate = model.FromDate; bookingTbl.ToDate = model.ToDate; bookingTbl.BookingDate = model.BookingDate; bookingTbl.BuyingPrice = model.BuyingPrice; bookingTbl.BuyingCurrency = model.BuyingCurrency; bookingTbl.CreatedOn = System.DateTime.Now.ToShortDateString(); _hotelEntities.Entry(bookingTbl).State = System.Data.Entity.EntityState.Added; _hotelEntities.SaveChanges(); result = "Record Inserted"; } catch (Exception) { result = "Failed To Insert"; } return(result); } }
public string AddHotel(HotelModel model) { string result = string.Empty; using (HotelDBContext _hotelEntities = new HotelDBContext()) { try { Hotel hotel = new Hotel(); hotel.HotelName = model.HotelName; hotel.Address = model.Address; hotel.CityId = model.CityId; hotel.CountryId = model.CountryId; hotel.PhoneNumber = model.PhoneNumber; hotel.Description = model.Description; hotel.CancellationPolicy = model.CancellationPolicy; hotel.DefaultCurrency = model.DefaultCurrency; hotel.PricePerNight = model.PricePerNight; hotel.CreatedOn = System.DateTime.Now.ToShortDateString(); _hotelEntities.Entry(hotel).State = System.Data.Entity.EntityState.Added; _hotelEntities.SaveChanges(); result = "Record Inserted"; } catch (Exception) { result = "Failed To Insert"; } return(result); } }
public IHttpActionResult PutFacility(int id, Facility facility) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != facility.Facility_No) { return(BadRequest()); } db.Entry(facility).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FacilityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public string UpdateRoom(RoomTypeModel roomType) { string result = string.Empty; using (HotelDBContext _hotelEntities = new HotelDBContext()) { try { RoomType roomTbl = new RoomType(); roomTbl.Id = roomType.Id; roomTbl.RoomName = roomType.RoomName; roomTbl.Amenities = roomType.Amenities; roomTbl.ImagePath = roomType.ImagePath; roomTbl.ModifiedOn = System.DateTime.Now.ToShortDateString(); _hotelEntities.RoomTypes.Add(roomTbl); _hotelEntities.Entry(roomTbl).State = System.Data.Entity.EntityState.Modified; _hotelEntities.SaveChanges(); result = "Record Updated"; } catch (Exception) { result = "Failed To Upadate"; } return(result); } }
public string AddTraveller(TravellerModel travellerModel) { string result = string.Empty; using (HotelDBContext travellerEntities = new HotelDBContext()) { try { Traveller traveller = new Traveller(); traveller.FirstName = travellerModel.FirstName; traveller.MiddleName = travellerModel.MiddleName; traveller.LastName = travellerModel.LastName; traveller.MobileNo = travellerModel.MobileNo; traveller.EmailId = travellerModel.EmailId; traveller.Gender = travellerModel.Gender; traveller.Address = travellerModel.Address; traveller.FirstName_2 = travellerModel.FirstName_2; traveller.MiddleName_2 = travellerModel.MiddleName_2; traveller.LastName_2 = travellerModel.LastName_2; traveller.CreatedOn = System.DateTime.Now.ToShortDateString(); travellerEntities.Entry(traveller).State = System.Data.Entity.EntityState.Added; travellerEntities.SaveChanges(); result = "Record Inserted"; } catch (Exception ex) { Log.Error("Failed To Insert", ex); result = "Failed To Insert"; } return(result); } }
public string AddPayment(PaymentModel model) { string result = string.Empty; using (HotelDBContext dBEntities = new HotelDBContext()) { try { Payment paymentTbl = new Payment(); paymentTbl.BookingId = model.BookingId; paymentTbl.CardNumber = model.CardNumber; paymentTbl.NameOnCard = model.NameOnCard; paymentTbl.ExpiryDate = model.ExpiryDate; paymentTbl.Status = model.Status; paymentTbl.CreatedOn = System.DateTime.Now.ToShortDateString(); dBEntities.Entry(paymentTbl).State = System.Data.Entity.EntityState.Added; dBEntities.SaveChanges(); result = "Record Inserted"; } catch (Exception) { result = "Failed To Insert"; } return(result); } }
public ActionResult Edit([Bind(Include = "OrderID,FullName,Date,Phone,IdentifyDocument,Deposit,Deleted")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Edit([Bind(Include = "RoomID,TypeRoomID,CanUse,Image")] Room room) { if (ModelState.IsValid) { db.Entry(room).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TypeRoomID = new SelectList(db.TypeRooms, "TypeRoomID", "NameRoom", room.TypeRoomID); return(View(room)); }
public ActionResult Edit([Bind(Include = "ID,OrderID,RoomID,Fromdate,ToDate,Price")] OrderDetail orderDetail) { if (ModelState.IsValid) { db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { order = orderDetail.OrderID })); } ViewBag.OrderID = new SelectList(db.Orders, "OrderID", "FullName", orderDetail.OrderID); ViewBag.RoomID = new SelectList(db.Rooms, "RoomID", "RoomID", orderDetail.RoomID); return(View(orderDetail)); }
public ActionResult Edit([Bind(Include = "TypeRoomID,NameRoom,Capacity,Price,Description,Deleted")] TypeRoom typeRoom, HttpPostedFileBase image1) { if (ModelState.IsValid) { if (image1 != null) { typeRoom.Image = new byte[image1.ContentLength]; image1.InputStream.Read(typeRoom.Image, 0, image1.ContentLength); } db.Entry(typeRoom).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(typeRoom)); }
public async Task <IActionResult> PutHotel(int id, Hotel dHotel) { dHotel.Id = id; _context.Entry(dHotel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(T obj) { table.Attach(obj); _context.Entry(obj).State = EntityState.Modified; }