コード例 #1
0
        public ActionResult Create(BookingModel model)
        {
            TravelaEntities db       = new TravelaEntities();
            var             customer = new CustomerT()
            {
                customerid      = model.customerid,
                customername    = model.customername,
                customersurname = model.customersurname,
                birthdate       = model.birthdate,
                phone           = model.phone,
                email           = model.email,
                address         = model.address
            };


            var reservation = new ReservationT()
            {
                customerid        = model.customerid,
                hotelid           = model.hotelid,
                tourid            = model.tourid,
                status            = model.status = false,
                reservationnumber = model.reservationnumber = RandomGen2.Next()
            };


            db.CustomerT.Add(customer);
            db.ReservationT.Add(reservation);

            db.SaveChanges();

            return(Redirect("~/Web/Index"));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReservationT reservationT = db.ReservationT.Find(id);

            db.ReservationT.Remove(reservationT);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "reservationid,reservationnumber,customerid,tourid,status,hotelid")] ReservationT reservationT)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reservationT).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerid = new SelectList(db.CustomerT, "customerid", "customername", reservationT.customerid);
     ViewBag.hotelid    = new SelectList(db.HotelT, "hotelid", "hotelname", reservationT.hotelid);
     ViewBag.tourid     = new SelectList(db.TourT, "tourid", "tourname", reservationT.tourid);
     return(View(reservationT));
 }
コード例 #4
0
        // GET: ReservationTs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReservationT reservationT = db.ReservationT.Find(id);

            if (reservationT == null)
            {
                return(HttpNotFound());
            }
            return(View(reservationT));
        }
コード例 #5
0
        // GET: ReservationTs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReservationT reservationT = db.ReservationT.Find(id);

            if (reservationT == null)
            {
                return(HttpNotFound());
            }
            ViewBag.customerid = new SelectList(db.CustomerT, "customerid", "customername", reservationT.customerid);
            ViewBag.hotelid    = new SelectList(db.HotelT, "hotelid", "hotelname", reservationT.hotelid);
            ViewBag.tourid     = new SelectList(db.TourT, "tourid", "tourname", reservationT.tourid);
            return(View(reservationT));
        }