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

        }
Ejemplo n.º 2
0
 public ActionResult RentBooking(HomePageModel data)
 {
     //ViewBag.data = data.cloock_1 + "-" + data.rfProductId;
     return View();
 }
        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);

        }