public IActionResult CreateTourDetails(TourDetail model)
        {
            if (HttpContext.Session.GetString("ID") == null)
            {
                return(RedirectToAction("Login", "Admin"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    bool check = tourDetailRepository.checkID(model.ID);
                    if (check)
                    {
                        tourDetailRepository.addTourDetails(model);
                        return(View("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "This ID already exists.");
                        ViewBag.listAllTours  = tourDetailRepository.listAllTours();
                        ViewBag.listAllCities = tourDetailRepository.listAllCities();
                        return(View(model));
                    }
                }

                return(View(model));
            }
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            TourDetail tourDetail = db.TourDetails.Find(id);

            tourDetail.IsDelete   = true;
            tourDetail.DeleteDate = DateTime.Now;

            db.SaveChanges();
            return(RedirectToAction("Index", new{ id = tourDetail.Id }));
        }
Exemple #3
0
        public void EditTourDetail(TourDetail _TourDetail)
        {
            var dbEntity = db.tbl_TourDetail.Find(_TourDetail.ID);

            dbEntity.Date        = _TourDetail.Date;
            dbEntity.DateContent = _TourDetail.DateContent;
            dbEntity.Title       = _TourDetail.Title;
            dbEntity.TourID      = _TourDetail.TourID;
            dbEntity.CityID      = _TourDetail.CityID;

            db.SaveChanges();
        }
Exemple #4
0
 public ActionResult Edit(TourDetail tourDetail)
 {
     if (ModelState.IsValid)
     {
         tourDetail.IsDelete        = false;
         db.Entry(tourDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new{ id = tourDetail.TourId }));
     }
     ViewBag.TourId = tourDetail.TourId;
     return(View(tourDetail));
 }
Exemple #5
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TourDetail tourDetail = db.TourDetails.Find(id);

            if (tourDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(tourDetail));
        }
Exemple #6
0
        public ActionResult Create(TourDetail tourDetail, Guid id)
        {
            if (ModelState.IsValid)
            {
                tourDetail.TourId     = id;
                tourDetail.IsDelete   = false;
                tourDetail.SubmitDate = DateTime.Now;
                tourDetail.Id         = Guid.NewGuid();
                db.TourDetails.Add(tourDetail);
                db.SaveChanges();
                return(RedirectToAction("Index", new{ id = id }));
            }

            ViewBag.TourId = id;
            return(View(tourDetail));
        }
        public static TourDetail FillObject(IDataReader _dr)
        {
            List <TourDetail> _list = new List <TourDetail>();

            try
            {
                while (_dr.Read())
                {
                    TourDetail tourDetail = new TourDetail();
                    tourDetail.Id           = ConvertHelper.ToGuid(_dr["Id"], Guid.Empty);
                    tourDetail.TypeTourId   = ConvertHelper.ToInt32(_dr["TypeTourId"], 0);
                    tourDetail.TenTour      = ConvertHelper.ToString(_dr["TenTour"], string.Empty);
                    tourDetail.GioiThieu    = ConvertHelper.ToString(_dr["GioiThieu"], string.Empty);
                    tourDetail.NoiDung      = ConvertHelper.ToString(_dr["NoiDung"], string.Empty);
                    tourDetail.GiaTour      = ConvertHelper.ToInt64(_dr["GiaTour"], 0);
                    tourDetail.DiemKhoiHanh = ConvertHelper.ToString(_dr["DiemKhoiHanh"], string.Empty);
                    tourDetail.TimeKhoiHanh = ConvertHelper.ToDateTime(_dr["TimeKhoiHanh"], DateTime.Now);
                    tourDetail.SoNgay       = ConvertHelper.ToInt32(_dr["SoNgay"], 0);
                    tourDetail.SoDem        = ConvertHelper.ToInt32(_dr["SoDem"], 0);
                    tourDetail.HinhAnh      = ConvertHelper.ToString(_dr["HinhAnh"], string.Empty);
                    tourDetail.Sale         = ConvertHelper.ToInt32(_dr["Sale"], 0);

                    tourDetail.CreatedBy = ConvertHelper.ToString(_dr["CreatedBy"], string.Empty);
                    tourDetail.CreatedAt = ConvertHelper.ToDateTime(_dr["CreatedAt"], DateTime.Now);
                    tourDetail.UpdatedBy = ConvertHelper.ToString(_dr["UpdatedBy"], string.Empty);
                    tourDetail.UpdatedAt = ConvertHelper.ToDateTime(_dr["UpdatedAt"], DateTime.Now);
                    tourDetail.IsDeleted = ConvertHelper.ToInt32(_dr["IsDeleted"], 0);
                    if (_list.IndexOf(tourDetail) < 0)
                    {
                        _list.Add(tourDetail);
                    }
                    if (_list.Count > 0)
                    {
                        TourDetail[] tourDetails = _list.ToArray();
                        if (tourDetails != null && tourDetails.Length > 0)
                        {
                            return(tourDetails[0]);
                        }
                    }
                }
            }
            finally
            {
                _dr.Close();
            }
            return(null);
        }
 public IActionResult EditTourDetails(TourDetail model)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (ModelState.IsValid)
         {
             tourDetailRepository.EditTourDetail(model);
             return(RedirectToAction("Index"));
         }
         ViewBag.listAllTours  = tourDetailRepository.listAllTours();
         ViewBag.listAllCities = tourDetailRepository.listAllCities();
         return(View(model));
     }
 }
 public IActionResult DeleteTourDetails(int?Id)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (Id == null)
         {
             //Error
             return(RedirectToAction("NotFoundPage", "Home"));
         }
         else
         {
             TourDetail model = tourDetailRepository.GettourDetail(Id);
             return(View(model));
         }
     }
 }
        public TourDetail GetById(string id)
        {
            TourDetail tourDetail = new TourDetail();

            try
            {
                Database  db        = this.GetDatabase();
                string    storeName = "TourDetail_GetById";
                DbCommand dbCommand = db.GetStoredProcCommand(storeName);
                db.AddInParameter(dbCommand, "Id", DbType.Guid, Guid.Parse(id));
                using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                {
                    tourDetail = FillObject(dataReader);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(tourDetail);
        }
        private void btnAddRoute_Click(object sender, EventArgs e)
        {
            TourDetail last = _routes.Count == 0?null:_routes.Last();
            var        item = (DataRowView)this.listLocation.SelectedItem;

            if (item == null)
            {
                MessageBox.Show("Chưa chọn địa điểm muốn thêm", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }

            var temp = new TourDetail(0, Int32.Parse(item["Id"].ToString()), ++_routeOrder);

            if (last != null)
            {
                if (last.LocationId.Equals(temp.LocationId))
                {
                    MessageBox.Show("Địa diểm kế tiếp cần phải khác địa điểm kết thúc hiện tại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
            }

            _routes.Add(temp);
            LoadRoutes();
        }
 public ExcutionResult Delete(TourDetail employess)
 {
     throw new NotImplementedException();
 }
 public ExcutionResult Update(TourDetail employees)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 public void addTourDetails(TourDetail _TourDetail)
 {
     db.tbl_TourDetail.Add(_TourDetail);
     db.SaveChanges();
 }