Exemple #1
0
        public ActionResult CreatNhaHang(PasgoRestaurant model)
        {
            ViewBag.Promotions = db.Promotions.ToList();
            ViewBag.Cities     = db.Cities.ToList();
            if (model.RpromotionPercent != 0)
            {
                model.Rpromotion = model.Rpromotion + " " + model.RpromotionPercent + "%";
            }
            var result = db.UpdateInsertRestaurantInfo(0, model.RName, model.Rlink, model.Rpromotion, model.Rstar, model.Rdollar, model.Raddress, model.Rcity,
                                                       model.RpromotionPercent, model.Rfeature, model.RLoaiHinh, model.RPhuHop, model.RKhongGian, model.RChoDeXe, model.RDacTrung, model.RThongTinThem,
                                                       model.RGioiThieu, 2).ToList().ElementAt(0);

            System.Diagnostics.Trace.WriteLine("add: ");
            System.Diagnostics.Trace.WriteLine(model.Raddress + " / " + model.RChoDeXe + " / " + model.Rcity + " / " + model.Rdollar + " / " + model.Rstar);
            int status = Convert.ToInt32(result);

            ViewBag.RID = "none";
            if (status == 0)
            {
                ViewBag.UpdateFailed = "Tạo nhà hàng thất bại";
            }
            if (status == 2)
            {
                ViewBag.UpdateFailed = "Tạo nhà hàng thất bại. Nhà hàng tạo có tên/địa chỉ/đường dẫn bị trùng với nhà hàng khác trong CSDL.";
            }
            if (status != 0 && status != 2)
            {
                ViewBag.UpdateSuccess = "Tạo nhà hàng thành công.";
                ViewBag.RID           = status;
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult UpdateDetails(PasgoRestaurant R)
        {
            if (Convert.ToInt32(Session["Level"]) == 1 || Session["Level"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            System.Diagnostics.Trace.WriteLine("test post");
            System.Diagnostics.Trace.WriteLine(R.PasgoRID.ToString());
            System.Diagnostics.Trace.WriteLine(R.RName);
            var ok = db.UpdateInsertRestaurantInfo(R.PasgoRID, R.RName, R.Rlink, R.Rpromotion, R.Rstar, R.Rdollar,
                                                   R.Raddress, R.Rcity, R.RpromotionPercent, R.Rfeature, R.RLoaiHinh, R.RPhuHop, R.RKhongGian,
                                                   R.RChoDeXe, R.RDacTrung, R.RThongTinThem, R.RGioiThieu, 1).ToList().ElementAt(0);
            //Update thành công nhưng không nhận được thông số?
            //ok này trả về một list chứa 1 element và có duy nhất 1 cột thông báo
            int status = Convert.ToInt32(ok);

            if (status == 0)
            {
                ViewBag.UpdateFailed = "Xảy ra lỗi, cập nhật thất bại.";
            }
            if (status == 1)
            {
                ViewBag.UpdateSuccess = "Cập nhật thông tin thành công.";
            }
            if (status == 2)
            {
                ViewBag.UpdateSuccess = "Không tìm thấy nhà hàng, cập nhật thất bại.";
            }
            return(View(R));
        }
Exemple #3
0
        public ActionResult UpdateDetails(int?Rid)
        {
            if (Convert.ToInt32(Session["Level"]) == 1)
            {
                return(View("Index", "Home"));
            }
            if (Rid == null)
            {
                return(RedirectToAction("Index", "NhaHang"));
            }
            PasgoRestaurant results = db.FullInfoRestaurant(Rid).ElementAt(0);

            return(View(results));
        }
Exemple #4
0
        public ActionResult Details(int?Rid)
        {
            if (Convert.ToInt32(Session["Level"]) == 1 || Session["Level"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (Rid == null)
            {
                return(RedirectToAction("Index", "NhaHang"));
            }
            var a = db.FullInfoRestaurant(Rid).Count();

            if (a == 0)
            {
                TempData["Failed"] = "Không tồn tại nhà hàng trong CSDL.";
                return(RedirectToAction("Index", "NhaHang"));
            }
            PasgoRestaurant results = db.FullInfoRestaurant(Rid).ElementAt(0);

            List <allImg_Result>         resultsimg = new List <allImg_Result>();
            List <thongtinthemSP_Result> resulttt   = new List <thongtinthemSP_Result>();
            //Nếu nhà hàng không có trong danh sách thuộc thương hiệu thì ds trả về = null -> lỗi, không push object null đc
            var listchuoi = db.ThuocThuongHieuChuoi(Rid);
            ThuocThuongHieuChuoi_Result resultchuoi = new ThuocThuongHieuChuoi_Result();
            ThuocThuongHieuChuoi_Result thaydoi     = new ThuocThuongHieuChuoi_Result {
                IdThuongHieu = 0, Name = "(Chưa cập nhật)", AddressDT = "(Chưa cập nhật)", LinkTH = "https://via.placeholder.com/400x210.png?text=ch%C6%B0a+c%E1%BA%ADp+nh%E1%BA%ADt", ImgDT = "https://via.placeholder.com/400x210.png?text=ch%C6%B0a+c%E1%BA%ADp+nh%E1%BA%ADt", ImgTH = "(Chưa cập nhật)"
            };

            if (listchuoi.Count() == 0)
            {
                resultchuoi = thaydoi;
            }
            else
            {
                resultchuoi = db.ThuocThuongHieuChuoi(Rid).ElementAt(0);
            }
            var rsimg = db.allImg(Rid);
            var rstt  = db.thongtinthemSP(Rid);

            foreach (var item in rsimg.ToList())
            {
                resultsimg.Add(item);
            }
            foreach (var item in rstt.ToList())
            {
                resulttt.Add(item);
            }
            return(View(Tuple.Create(results, resultsimg.ToList(), resulttt.ToList(), resultchuoi)));
        }