Esempio n. 1
0
 public bool Update(tblTOUR entity)
 {
     try
     {
         var tour = db.tblTOURs.Find(entity.matour);
         tour.tentour     = entity.tentour;
         tour.chitiettour = entity.chitiettour;
         tour.hinhanh     = entity.hinhanh;
         tour.socho       = entity.socho;
         tour.giatour     = entity.giatour;
         tour.khoihanh    = entity.khoihanh;
         tour.ketthuc     = entity.ketthuc;
         tour.madd        = entity.madd;
         tour.phuongtien  = entity.phuongtien;
         TimeSpan remtime = entity.ketthuc - entity.khoihanh;
         int      songay  = remtime.Days + 1;
         tour.thoigian = songay.ToString() + " ngày," + songay.ToString() + " đêm";
         string metatitle = ToAscii(entity.tentour);
         tour.metatitle = metatitle;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 2
0
        public long Insert(tblTOUR entity)
        {
            TimeSpan remtime = entity.ketthuc - entity.khoihanh;
            int      songay  = remtime.Days + 1;

            entity.thoigian = songay.ToString() + " ngày," + songay.ToString() + " đêm";
            string metatitle = ToAscii(entity.tentour);

            entity.metatitle = metatitle;
            db.tblTOURs.Add(entity);
            db.SaveChanges();
            return(entity.matour);
        }
 public ActionResult Edit(tblTOUR tour)
 {
     if (ModelState.IsValid)
     {
         var dao    = new TourDAO();
         var result = dao.Update(tour);
         if (result)
         {
             return(RedirectToAction("Index", "Tour"));
         }
         else
         {
             ModelState.AddModelError("", "Sửa tour không thành công");
         }
     }
     return(View("Edit"));
 }
        public ActionResult Create(tblTOUR tour)
        {
            if (ModelState.IsValid)
            {
                var  dao = new TourDAO();
                long id  = dao.Insert(tour);

                if (id > 0)
                {
                    return(RedirectToAction("Index", "Tour"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm tour không thành công");
                }
            }
            SetViewBag();
            return(View("Create"));
        }