Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            gia gia = db.gias.Find(id);

            db.gias.Remove(gia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "Id,SoTien,IdTour,TuNgay,DenNgay")] gia gia)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gia).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdTour = new SelectList(db.tours, "Id", "Ten", gia.IdTour);
     return(View(gia));
 }
Exemple #3
0
        // GET: gias/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            gia gia = db.gias.Find(id);

            if (gia == null)
            {
                return(HttpNotFound());
            }
            return(View(gia));
        }
Exemple #4
0
        // GET: gias/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            gia gia = db.gias.Find(id);

            if (gia == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdTour = new SelectList(db.tours, "Id", "Ten", gia.IdTour);
            return(View(gia));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "Id,SoTien,IdTour,TuNgay,DenNgay")] gia gia)
        {
            if (ModelState.IsValid)
            {
                db.gias.Add(gia);
                db.SaveChanges();
                return(RedirectToAction("Details", "tours", new { id = gia.IdTour }));
            }
            int id    = Convert.ToInt32(Request.QueryString["id"]);
            var tours = db.tours.Find(id);

            ViewBag.TourId  = id;
            ViewBag.TourTen = tours.Ten;
            return(View(gia));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "Id,Ten,MoTa,IdLoaiTour,IdGiaTour")] tour tour, [Bind(Include = "Id,SoTien,IdTour,TuNgay,DenNgay")] gia gia)
        {
            var t = db.tours.FirstOrDefault();

            //gia.SoTien = 0;//Hiển thị
            gia.IdTour = t.Id;
            //gia.TuNgay = DateTime.Now;//Hiển thị
            //gia.DenNgay = DateTime.Now;//Hiển thị
            db.gias.Add(gia);
            db.SaveChanges();
            tour.IdGiaTour = gia.Id;

            if (ModelState.IsValid)
            {
                db.tours.Add(tour);
                db.SaveChanges();
                gia.IdTour          = tour.Id;
                db.Entry(gia).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details", "tours", new { id = tour.Id }));
            }
            ViewBag.IdLoaiTour = new SelectList(db.loais, "Id", "Ten", tour.IdLoaiTour);
            return(View(tour));
        }