public ActionResult Booking(HomePageModel data)
        {
            #region queryString kontrolü

            string catguid = Request.QueryString["cat"];
            string prod_ = Request.QueryString["prod"];

            ErrorLog error = new ErrorLog();
            dm = new SeyahatIstanbulEntities();

            if (Session["kId"] == null)
            {
                error.dgErrorCode = 1;
                error.chError = "Üye girişi yapılmadan rezarvasyon yapılmaya çalışılıyor";
                error.chPageName = "Booking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return RedirectToAction("Index", "Home");
            }
            else if (catguid == "" || prod_ == "")
            {
                error.dgErrorCode = 1;
                error.chError = "Doğru linkle giriş yapılmıyor";
                error.chPageName = "Booking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return RedirectToAction("Index", "Home");
            }

            #endregion

            #region category ve productId



            Category cat = (from c in dm.Category
                            where 1 == 1
                               && c.blStatus == true
                               && c.chGuid == catguid
                            select c).SingleOrDefault();

            if (cat == null)
                return RedirectToAction("Index", "Home");
            else
                return RedirectToAction(cat.chUrl, new { prod = prod_ });

            #endregion

        }
        public ActionResult Vehicle()
        {
            string prod_ = Request.QueryString["prod"];
            ErrorLog error = new ErrorLog();
            dm = new SeyahatIstanbulEntities();

            if (Session["kId"] == null)
            {
                error.dgErrorCode = 1;
                error.chError = "Üye girişi yapılmadan rezarvasyon yapılmaya çalışılıyor";
                error.chPageName = "Vehicle/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return RedirectToAction("Index", "Home");
            }
            else if (prod_ == "")
            {
                error.dgErrorCode = 1;
                error.chError = "Doğru linkle giriş yapılmıyor";
                error.chPageName = "Booking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return RedirectToAction("Index", "Home");
            }
            int prod;
            try
            {
                prod = Convert.ToInt32(prod_);
            }
            catch (Exception)
            {

                throw;
            }

            SettingController set = new SettingController();
            List<VehicleList> vehicleList = set.loadVehicleList().Where(d => d.dgVehicleId == prod).ToList();

            ViewBag.Clock = set.ddClock();
            ViewBag.TabVehicleList = set.ddVehicleList();
            ViewBag.VehicleDeliveryPlace = set.ddVehicleDeliveryPlace();


            ViewBag.VehicleList = vehicleList;

            return View();
        }
        public ActionResult Register(Customer cus)
        {
            int durum = -2;
            //return Json(durum, JsonRequestBehavior.AllowGet);
            if (ModelState.IsValid)
            {
                try
                {
                    dm = new SeyahatIstanbulEntities();

                    var find = (from c in dm.Customer
                                where c.chEmail == cus.chEmail
                                select c).ToList();
                    if (find.Count != 0)
                    {
                        durum = -1;
                        return Json(durum, JsonRequestBehavior.AllowGet);
                    }
                    cus.cdCreator = "İnternet";
                    cus.dtCreated = DateTime.Now;
                    dm.Customer.Add(cus);
                    dm.SaveChanges();
                    durum = 1;
                    Session["kId"] = (from c in dm.Customer
                                      where c.chEmail == cus.chEmail
                                      select new { id = c.sqCustomerId }).FirstOrDefault().ToString();
                    Session["kAdSoyad"] = cus.chName + " " + cus.chSurname;
                }
                catch (Exception)
                {

                    durum = -2;
                }

                return Json(durum, JsonRequestBehavior.AllowGet);
            }
            return Json(durum, JsonRequestBehavior.AllowGet);
        }
        public ActionResult TourBooking(HomePageModel data)
        {
            dm = new SeyahatIstanbulEntities();
            ErrorLog error = new ErrorLog();

            //kullanıcı kontrol
            if (Session["kId"] == null)
            {
                error.dgErrorCode = 1;
                error.chError = "Üye girişi yaplısınız";
                error.chPageName = "VehicleBooking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return Json(error, JsonRequestBehavior.AllowGet);
            }
            int cusId = Convert.ToInt32(Session["kId"]);

            #region ekrandan alınan bilgiler

            DateTime startDate = new DateTime();
            Int16 catId = 3;
            int prodId = 0;
            string c_1 = "";

            try
            {
                c_1 = data.tourCloock_1;
                startDate = Convert.ToDateTime(data.dtTourDate + " " + c_1);
                prodId = Convert.ToInt32(data.rfTourId);
            }
            catch (Exception)
            {
                error.dgErrorCode = 2;
                error.chError = "Alanlar boş geçilemez";
                error.chPageName = "TourBooking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return Json(error, JsonRequestBehavior.AllowGet);
            }
            #endregion
            #region bilgi kontrolleri
            if (startDate < DateTime.Now)
            {
                error.dgErrorCode = 3;
                error.chError = "Seçilen tarih şuan tarihten küçük olamaz";
                error.chPageName = "TourBooking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return Json(error, JsonRequestBehavior.AllowGet);
            }
            #endregion

            List<Process> processList = (from p in dm.Process
                                         where p.rfCustomerId == cusId
                                            && p.blStatus == true
                                            && (p.rfStatusId == 1 || p.rfStatusId == 2)
                                         select p).ToList();
            Customer customer = (from c in dm.Customer
                                 where c.sqCustomerId == cusId
                                 select c).SingleOrDefault();

            #region 1-> Müşteri krumsal değilse rezarvasyonda çakışan tarih var mı?
            List<Process> cakisanRezarvasyon = processList.Where(d => d.rfCategoryId == 3 && d.dtStartDate == startDate).ToList();

            if (cakisanRezarvasyon.Count() != 0 && customer.rfCustomerTypeId != 3)
            {
                error.dgErrorCode = 5;
                error.chError = "<p style=\"text-align:Justify;\"> Çakışan rezarvasyonunuz var.! <br /><br />" + String.Format("{0:dd.MM.yyyy}", cakisanRezarvasyon[0].dtStartDate) + " tarihinde yaptığınız rezarvasyonun ödemesini yaptıktan sonra başka rezarvasyon yapabilirsiniz </p> ";
                error.chPageName = "ApartBooking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return Json(error, JsonRequestBehavior.AllowGet);

            }
            #endregion
            #region 2-> 3'ten fazla rezarvayon var mı
            if (processList.Count() >= 3 && customer.rfCustomerTypeId != 3)
            {
                error.dgErrorCode = 6;
                error.chError = "Ödeme yapmadan 3 ten fazla rezarvasyon yapamazsınız";
                error.chPageName = "VehicleBooking/BookingController";
                error.dtCreated = DateTime.Now;
                error.chIpAddress = Request.UserHostAddress;
                dm.ErrorLog.Add(error);
                dm.SaveChanges();
                return Json(error, JsonRequestBehavior.AllowGet);
            }
            #endregion

            Price price = (from p in dm.Price
                           where p.rfCategoryId == catId
                              && p.rfProductId == prodId
                              && p.blStatus == true
                           select p).OrderByDescending(d => d.dtCreated).FirstOrDefault();//hatalı olarak iki fiyat olsda en son eklenen alınacak

            int totalPrice = Convert.ToInt32(price.dgValue);

            int processStatus;
            if (customer.rfCustomerTypeId == 1)
                processStatus = 1;
            else
                processStatus = 2;

            Process process = new Process()
            {
                rfCategoryId = catId,
                rfProductId = prodId,
                rfCustomerId = cusId,
                dtStartDate = Convert.ToDateTime(startDate.ToShortDateString() + " " + c_1),
                rfStatusId = processStatus,
                dgPrice = totalPrice,
                blStatus = true,
                dtCreated = DateTime.Now,
                cdCreator = "İnternet"
            };

            dm.Process.Add(process);
            dm.SaveChanges();

            error.dgErrorCode = 0;
            error.chError = "Kaydınız başarıyla oluşmuştur";
            error.chPageName = "VehicleBooking/BookingController";
            error.dtCreated = DateTime.Now;
            error.chIpAddress = Request.UserHostAddress;

            return Json(error, JsonRequestBehavior.AllowGet);

        }
        public void bookingSettings()
        {
            dm = new SeyahatIstanbulEntities();

            CommonSettings sonControl = (from cs in dm.CommonSettings
                                 where 1 == 1
                                    && cs.blStatus == true
                                    && cs.chKey == "bookingControl"
                                 select cs).SingleOrDefault();

            DateTime dtSonControl = Convert.ToDateTime(sonControl.chValue);

            if (dtSonControl >=DateTime.Now.Date)
                return;

            DateTime bugun = DateTime.Now.Date;
            List<Process> pGecmisList = (from p in dm.Process
                                   where 1 == 1
                                      && p.blStatus == true
                                      && (p.rfStatusId == 1 || p.rfStatusId == 2 || p.rfStatusId == 3)
                                      &&  p.dtStartDate < bugun
                                   select p).ToList();

            foreach (var item in pGecmisList)
            {
                item.rfStatusId = 8;
                dm.SaveChanges();

                sonControl.chValue = bugun.ToString();
                dm.SaveChanges();
            }


        }