Exemple #1
0
        public string Create(CustomerPopupModel model)
        {
            try
            {
                TravelaEntities db       = new TravelaEntities();
                CustomerT       customer = null;
                if (model.customerid > 0)
                {
                    customer = db.CustomerT.FirstOrDefault(f => f.customerid == model.customerid);
                }
                else
                {
                    customer = new CustomerT();
                }

                customer.customername    = model.customername;
                customer.customersurname = model.customersurname;
                customer.birthdate       = model.birthdate;
                customer.phone           = model.phone;
                customer.email           = model.email;
                customer.address         = model.address;

                if (model.customerid == 0)
                {
                    db.CustomerT.Add(customer);
                }

                return(db.SaveChanges().ToString());
            }
            catch
            {
                return("-1");
            }
        }
Exemple #2
0
        public ActionResult Create(BookingModel model)
        {
            TravelaEntities db       = new TravelaEntities();
            var             customer = new CustomerT()
            {
                customerid      = model.customerid,
                customername    = model.customername,
                customersurname = model.customersurname,
                birthdate       = model.birthdate,
                phone           = model.phone,
                email           = model.email,
                address         = model.address
            };


            var reservation = new ReservationT()
            {
                customerid        = model.customerid,
                hotelid           = model.hotelid,
                tourid            = model.tourid,
                status            = model.status = false,
                reservationnumber = model.reservationnumber = RandomGen2.Next()
            };


            db.CustomerT.Add(customer);
            db.ReservationT.Add(reservation);

            db.SaveChanges();

            return(Redirect("~/Web/Index"));
        }
        // GET: PagedCustomer
        public ActionResult Index(CustomerModel model)
        {
            int pageIndex = model.page ?? 1;

            TravelaEntities db = new TravelaEntities();

            model.Customers = (from cust in db.CustomerT.Where(f =>
                                                               (String.IsNullOrEmpty(model.email) || f.email.Contains(model.email)) &&
                                                               (String.IsNullOrEmpty(model.phone) || f.phone.Contains(model.phone))
                                                               ).OrderByDescending(f => f.customerid)
                               select new CustomerListModel
            {
                customername = cust.customername,
                customersurname = cust.customersurname,
                email = cust.email,
                phone = cust.phone
            }).ToPagedList(pageIndex, 10);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Customer", model));
            }
            else
            {
                return(View(model));
            }
        }
Exemple #4
0
        public ActionResult ListBooking()
        {
            TravelaEntities db = new TravelaEntities();

            var list = (from cus in db.CustomerT
                        join rez in db.ReservationT on cus.customerid equals rez.customerid

                        select new BookingModel {
                customername = cus.customername, customersurname = cus.customersurname, reservationnumber = rez.reservationnumber, status = rez.status
            });

            return(View(list.ToList()));
        }
        public JsonResult HotelList(int id)
        {
            TravelaEntities db        = new TravelaEntities();
            List <HotelT>   hotelList = db.HotelT.Where(f => f.tourid == id).OrderBy(f => f.hotelname).ToList();

            List <SelectListItem> itemList = (from i in hotelList
                                              select new SelectListItem
            {
                Text = i.hotelname,
                Value = i.hotelid.ToString(),
            }).ToList();

            return(Json(itemList, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        public JsonResult Getir(int id)
        {
            TravelaEntities    db       = new TravelaEntities();
            CustomerT          customer = db.CustomerT.FirstOrDefault(f => f.customerid == id);
            CustomerPopupModel model    = new CustomerPopupModel();

            model.customerid      = customer.customerid;
            model.customername    = customer.customername;
            model.customersurname = customer.customersurname;
            model.birthdate       = customer.birthdate;
            model.phone           = customer.phone;
            model.email           = customer.email;
            model.address         = customer.address;
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index(BookingModel model)
        {
            TravelaEntities db = new TravelaEntities();

            //toplam rezervation sayısı
            var rezercount = (from rezz in db.ReservationT select new { resevationnumber = rezz.reservationnumber }).Count();

            ViewBag.rezercount1 = rezercount;

            //onay bekleyenler
            var rezercountfalse = (from cus in db.CustomerT
                                   join rez in db.ReservationT on cus.customerid equals rez.customerid
                                   where rez.status == false

                                   select new BookingModel
            {
                customername = cus.customername
            }).Count();

            ViewBag.rezercountfalse2 = rezercountfalse;

            //hotellerin sayısı
            var hotelcount = (from hotel in db.HotelT select new { hotelname = hotel.hotelname }).Count();

            ViewBag.hotelcount = hotelcount;

            //londraya olan tour a isteklerin sayısı
            var tourcount1 = (from rezer in db.ReservationT

                              where rezer.tourid == 1
                              select new { tourid = rezer.tourid }).Count();

            ViewBag.tour1 = tourcount1;


            //oxforda olan tour a isteklerin sayısı
            var tourcount2 = (from rezer in db.ReservationT

                              where rezer.tourid == 3
                              select new { tourid = rezer.tourid }).Count();

            ViewBag.tour2 = tourcount2;


            return(View());
        }
Exemple #8
0
        public PartialViewResult CustomerList()
        {
            TravelaEntities db = new TravelaEntities();

            List <CustomerPopupModel> customerList = (from k in db.CustomerT
                                                      select new CustomerPopupModel
            {
                customerid = k.customerid,
                customername = k.customername,
                customersurname = k.customersurname,
                birthdate = k.birthdate,
                phone = k.phone,
                email = k.email,
                address = k.address
            }).OrderByDescending(f => f.customerid).ToList();

            return(PartialView(customerList));
        }
Exemple #9
0
        public ActionResult Login(LoginModel model)
        {
            TravelaEntities db = new TravelaEntities();

            var usr = db.UserT.Where(u => u.username == model.username && u.userpassword == model.userpassword).FirstOrDefault();

            if (usr != null)
            {
                Session["username"]     = usr.username.ToString();
                Session["userpassword"] = usr.userpassword.ToString();

                return(Redirect("~/Home"));
            }
            else
            {
                ModelState.AddModelError("err", "Please enter correct information");
            }
            return(View());
        }
Exemple #10
0
        public ActionResult Index()
        {
            BookingModel    model = new BookingModel();
            TravelaEntities db    = new TravelaEntities();

            List <TourT> tourList = db.TourT.OrderBy(f => f.tourname).ToList();

            model.TourTList = (from s in tourList
                               select new SelectListItem
            {
                Text = s.tourname,
                Value = s.tourid.ToString()
            }).ToList();

            model.TourTList.Insert(0, new SelectListItem {
                Value = "", Text = "Select", Selected = true
            });

            return(View(model));
        }