public IActionResult Index([FromQuery] int seat, [FromQuery] string cateprice, [FromQuery] string routeprice, [FromQuery] int RouteId)
        {
            if (CookieSupport.CheckCookieExists(HttpContext, CookieSupport.InfoBooking) == false)
            {
                return(RedirectToAction("index", "home"));
            }
            BookingView inforBooking = JsonConvert.DeserializeObject <BookingView>(HttpContext.Request.Cookies[CookieSupport.InfoBooking]);

            inforBooking.SeatId        = seat;
            inforBooking.CategoryPrice = Convert.ToDecimal(cateprice);
            inforBooking.RoutePrice    = Convert.ToDecimal(routeprice);
            inforBooking.RouteId       = RouteId;
            var route = _IRou.GetRouteById(inforBooking.RouteId);

            inforBooking.BusId = route.BusId;
            if (CookieSupport.CheckCookieExists(HttpContext, CookieSupport.InfoBooking))
            {
                CookieSupport.Remove(HttpContext, CookieSupport.InfoBooking);
                CookieSupport.Set(HttpContext, CookieSupport.InfoBooking, JsonConvert.SerializeObject(inforBooking), DateTime.Now.Minute + 5);

                BookingView inforBooking2 = JsonConvert.DeserializeObject <BookingView>(HttpContext.Request.Cookies[CookieSupport.InfoBooking]);
            }
            else
            {
                CookieSupport.Set(HttpContext, CookieSupport.InfoBooking, JsonConvert.SerializeObject(inforBooking), DateTime.Now.Minute + 5);
            }
            return(View());
        }
        // GET: Booking/Edit/5
        public ActionResult Edit(int?id)
        {
            List <SelectListItem> VehicleId = new List <SelectListItem>();

            foreach (var item in _vehicleManager.getVehicles(User.Identity.Name))
            {
                VehicleId.Add(new SelectListItem {
                    Text = item.Model, Value = "" + item.Id
                });
            }
            List <SelectListItem> ServiceId = new List <SelectListItem>();

            foreach (var item in _serviceManager.GetServices())
            {
                ServiceId.Add(new SelectListItem {
                    Text = item.ServiceName, Value = "" + item.Id
                });
            }
            ViewData["VehicleId"] = VehicleId;
            ViewData["ServiceId"] = ServiceId;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BookingView booking = _bookingManager.GetBooking(id);

            if (booking == null)
            {
                return(HttpNotFound());
            }
            return(View(booking));
        }
        public ActionResult CheckIn(int idBooking, string tokenBook, int number)
        {
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + tokenBook).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;
            OrderDetailView     ord        = new OrderDetailView {
                NameService = number + " phòng (" + book.NameCateRoom + ") x " + book.DurationStay + " day(s)", PriceOrdD = book.PriceCateRoom, Quantity = number, Amount = book.PriceCateRoom * number * book.DurationStay
            };

            System.Threading.Tasks.Task <HttpResponseMessage> resOrd = GlobalVariables.client.PostAsJsonAsync("OrderService?idBook=" + book.IDBooking, ord);
            if (book.NumberRoom == book.CountRoomBook + number || book.NumberRoom == number)
            {
                HistoryBookingView full = new HistoryBookingView {
                    IDBook = idBooking, NameHisBook = "Check in đủ số lượng phòng đã đặt(CI)", DayCreateHisBook = DateTime.Now
                };
                HttpResponseMessage resHisfull = GlobalVariables.client.PostAsJsonAsync("HistoryBooking", full).Result;
            }
            else
            {
                HistoryBookingView less = new HistoryBookingView {
                    IDBook = idBooking, NameHisBook = "Check in chưa đủ số lượng phòng đã đặt(CI)", DayCreateHisBook = DateTime.Now
                };
                HttpResponseMessage resHisless = GlobalVariables.client.PostAsJsonAsync("HistoryBooking", less).Result;
            }
            return(RedirectToAction("InformationBooking", new { token = tokenBook }));
        }
        public ActionResult EditInfor(string token)
        {
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + token).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;

            return(View(book));
        }
        public ActionResult UpdateInfor(BookingView bv)
        {
            HttpResponseMessage res = GlobalVariables.client.PutAsJsonAsync("Customer/" + bv.IDBooking.ToString(), bv).Result;

            TempData["success"] = "Update information successfully!";
            return(RedirectToAction("InformationBooking", new { token = bv.TokenBooking }));
        }
Пример #6
0
        public IActionResult GetTimeAndRoutes([FromQuery] int fr, [FromQuery] int to, [FromQuery] string dDate, [FromQuery] int QtyTicket, [FromQuery] string frname, [FromQuery] string toname)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;

            var InfoBooking = new BookingView
            {
                StationFrom     = fr,
                StationTo       = to,
                DayStart        = DateTime.Parse(dDate),
                QuantityTicket  = QtyTicket,
                StationNameFrom = frname,
                StationNameTo   = toname
            };

            DateTime today = DateTime.Now;

            if (CookieSupport.CheckCookieExists(HttpContext, CookieSupport.InfoBooking))
            {
                CookieSupport.Remove(HttpContext, CookieSupport.InfoBooking);
                CookieSupport.Set(HttpContext, CookieSupport.InfoBooking, JsonConvert.SerializeObject(InfoBooking), today.Minute + 5);
            }
            else
            {
                CookieSupport.Set(HttpContext, CookieSupport.InfoBooking, JsonConvert.SerializeObject(InfoBooking), today.Minute + 5);
            }


            return(RedirectToAction("index", "selectedSeat"));
        }
        public ActionResult Create([Bind(Include = "Id,ServiceId,VehicleId,StartTime,EndTime,Status")] BookingView booking)
        {
            List <SelectListItem> VehicleId = new List <SelectListItem>();

            foreach (var item in _vehicleManager.getVehicles(User.Identity.Name))
            {
                VehicleId.Add(new SelectListItem {
                    Text = item.Model, Value = "" + item.Id
                });
            }
            List <SelectListItem> ServiceId = new List <SelectListItem>();

            foreach (var item in _serviceManager.GetServices())
            {
                ServiceId.Add(new SelectListItem {
                    Text = item.ServiceName, Value = "" + item.Id
                });
            }
            ViewData["VehicleId"] = VehicleId;
            ViewData["ServiceId"] = ServiceId;
            if (ModelState.IsValid)
            {
                booking.UserId = _userManager.findUser(User.Identity.Name).Id;
                _bookingManager.AddBooking(User.Identity.Name, booking);
                return(RedirectToAction("Index"));
            }

            return(View(booking));
        }
Пример #8
0
        private async void EditEventCommandExecuted(EventModel item)
        {
            // We should get event from EventDataUnit to use EventBookingView
            var events = await _eventsDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == item.Event.ID);

            var model = new EventModel(events.FirstOrDefault());

            RaisePropertyChanged("DisableParentWindow");

            var view = new BookingView(BookingViews.Event, model);

            view.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");

            if (view.DialogResult != null && view.DialogResult.Value)
            {
                _contactsDataUnit.EventsRepository.Refresh();

                events = await _contactsDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == model.Event.ID);

                Event = new EventModel(events.FirstOrDefault());
                await LoadLightEventDetails();

                model.RefreshItems();
            }
        }
Пример #9
0
 private IEnumerable <string> ExtractServices(BookingView booking)
 {
     return(from service in booking.Services
            where !service.ServiceCode.Contains("AIR") &&
            !service.ServiceCode.Contains("TAX")
            select service.ServiceCode.Trim());
 }
Пример #10
0
        public ActionResult OrderService(string token, int idSer)
        {
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + token).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;
            var res = GlobalVariables.client.GetAsync("Service/" + idSer).Result;

            TempData["ser"] = res.Content.ReadAsAsync <ServiceView>().Result;
            return(View(book));
        }
Пример #11
0
        // PUT api/<controller>/5
        public IHttpActionResult Put(int id, BookingView cv)
        {
            var cus = new Customer {
                NameCus = cv.NameCus, PhoneCus = cv.PhoneCus, AddressCus = cv.AddressCus, EmailCus = cv.EmailCus, IDCus = cv.IDCus
            };

            Repositories.UpdateCus(cus, id);
            return(Ok());
        }
        // POST api/<controller>
        public IHttpActionResult Post(BookingView bv)
        {
            var booking = new Booking {
                NumberRoom = bv.NumberRoom, DateIn = bv.DateIn, DateOut = bv.DateOut, DurationStay = bv.DurationStay, IDCateRoom = bv.IDCateRoom, IDCus = bv.IDCus, TokenBooking = bv.TokenBooking
            };

            Repositories.CreateBooking(booking);
            return(Ok());
        }
        // PUT api/<controller>/5
        public IHttpActionResult Put(int id, BookingView item)
        {
            var booking = new Booking {
                IDBooking = item.IDBooking, IDCus = item.IDCus, DateIn = item.DateIn, DateOut = item.DateOut, DayCreateBooking = item.DayCreateBooking, DurationStay = item.DurationStay, IDCateRoom = item.IDCateRoom, NumberRoom = item.NumberRoom, NewBooking = item.NewBooking, TokenBooking = item.TokenBooking
            };

            Repositories.UpdateBooking(booking);
            return(Ok());
        }
 public ActionResult SaveBooking(BookingView bv)
 {
     if (Session["book"] != null)
     {
         Session.Remove("book");
     }
     Session["book"] = bv as BookingView;
     return(RedirectToAction("RegisterCustomer"));
 }
        public ActionResult CreateBooking(CustomerView cv)
        {
            HttpResponseMessage resCus = GlobalVariables.client.PostAsJsonAsync("Customer", cv).Result;
            int         idCus          = resCus.Content.ReadAsAsync <int>().Result;
            string      tokenBooking   = LibraryHelper.Tokenizer.Generate(5);
            BookingView book           = new BookingView();

            book              = (BookingView)Session["book"];
            book.IDCus        = idCus;
            book.TokenBooking = tokenBooking;
            HttpResponseMessage resBook = GlobalVariables.client.PostAsJsonAsync("Booking", book).Result;

            if (resBook.IsSuccessStatusCode)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        MailAddress senderEmail   = new MailAddress("*****@*****.**", "ABCXYZ Hotel");
                        MailAddress receiverEmail = new MailAddress(cv.EmailCus, cv.NameCus);
                        string      password      = "******";
                        string      sub           = "Booking Successfully";
                        string      body          = "Hello, " + cv.NameCus + "!\n" +
                                                    "Thank you for your reservation to stay at the ABCXYZ hotel.\n" +
                                                    "Your booking code: " + tokenBooking + " .\n" +
                                                    "Link leading to your booking information: http://localhost:53561/Booking/InformationBooking?token=" + tokenBooking;
                        SmtpClient smtp = new SmtpClient
                        {
                            Host                  = "smtp.gmail.com",
                            Port                  = 25,
                            EnableSsl             = true,
                            DeliveryMethod        = SmtpDeliveryMethod.Network,
                            UseDefaultCredentials = false,
                            Credentials           = new NetworkCredential(senderEmail.Address, password)
                        };
                        using (MailMessage mess = new MailMessage(senderEmail, receiverEmail)
                        {
                            Subject = sub,
                            Body = body
                        })
                        {
                            smtp.Send(mess);
                        }
                        TempData["success"] = "Booking Successfully! Check your mail";
                        return(RedirectToAction("InformationBooking", new { token = tokenBooking }));
                    }
                }
                catch (Exception e)
                {
                    ViewBag.Error = "Some Error";
                    Console.WriteLine(e.Message);
                }
            }
            TempData["error"] = "Booking error!";
            return(RedirectToAction("RegisterCustomer"));
        }
Пример #16
0
        public void AddBooking(string name, BookingView booking)
        {
            UserView user     = _userrepository.findUser(name);
            Bookings bookings = mapper.Map <BookingView, Bookings>(booking);

            bookings.UserId = user.Id;
            bookings.Status = "Pending";
            db.Bookings.Add(bookings);
            db.SaveChanges();
        }
Пример #17
0
        private void OpenEventCommandExecute()
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new BookingView(BookingViews.Event, new EventModel(EventReminder.EventReminder.Event));

            window.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");
        }
Пример #18
0
 public void MakeBooking(BookingView booking)
 {
     _bookings.Add(new BookingView()
     {
         Id            = BookingView.nextId,
         ProductID     = booking.ProductID,
         DataOfBooking = booking.DataOfBooking,
         ClientName    = booking.ClientName
     });
     BookingView.nextId++;
 }
Пример #19
0
        public static BookingView ToViewEntity(Booking dataEntity)
        {
            BookingView viewEntity = new BookingView();

            viewEntity.Id               = dataEntity.Id;
            viewEntity.DataOfBooking    = dataEntity.DataOfBooking;
            viewEntity.LastDayOfBooking = dataEntity.LastDayOfBooking;
            viewEntity.ProductID        = dataEntity.ProductID;
            viewEntity.ClientName       = dataEntity.ClientName;
            return(viewEntity);
        }
Пример #20
0
        public static Booking ToDataEntity(BookingView viewEntity)
        {
            Booking dataEntity = new Booking();

            dataEntity.Id               = viewEntity.Id;
            dataEntity.ProductID        = viewEntity.ProductID;
            dataEntity.DataOfBooking    = viewEntity.DataOfBooking;
            dataEntity.LastDayOfBooking = viewEntity.LastDayOfBooking;
            dataEntity.ClientName       = viewEntity.ClientName;
            return(dataEntity);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BookingView booking = _bookingManager.GetBooking(id);

            if (booking.UserId != _userManager.findUser(User.Identity.Name).Id)
            {
                return(HttpNotFound());
            }
            _bookingManager.RemoveBooking(id);
            return(RedirectToAction("Index"));
        }
Пример #22
0
        public BookingView GetBooking(int?id)
        {
            Bookings b = db.Bookings.Find(id);

            if (b == null)
            {
                return(null);
            }
            BookingView booking = mapper.Map <Bookings, BookingView>(b);

            return(booking);
        }
Пример #23
0
 public NavigationModel(ContentWindow contentWindow)
 {
     _contentWindow  = contentWindow;
     _mainView       = new MainView();
     _settingsView   = new SettingsView();
     _bookingView    = new BookingView();
     _payView        = new PayView();
     _reportView     = new ReportView();
     _addBookingView = new AddBookingView();
     _clientView     = new ClientView();
     _personnelView  = new PersonnelView();
 }
        public ActionResult EditBooking(string token)
        {
            HttpResponseMessage res = GlobalVariables.client.GetAsync("CategoryRoom").Result;

            TempData["cate"] = res.Content.ReadAsAsync <IEnumerable <CategoryRoomView> >().Result;
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + token).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;

            TempData["in"]  = book.DateIn.Year + "-" + (book.DateIn.Month < 10 ? ("0" + Convert.ToString(book.DateIn.Month)) : Convert.ToString(book.DateIn.Month)) + "-" + (book.DateIn.Day < 10 ? ("0" + Convert.ToString(book.DateIn.Day)) : Convert.ToString(book.DateIn.Day));
            TempData["out"] = book.DateOut.Year + "-" + (book.DateOut.Month < 10 ? ("0" + Convert.ToString(book.DateOut.Month)) : Convert.ToString(book.DateOut.Month)) + "-" + (book.DateOut.Day < 10 ? ("0" + Convert.ToString(book.DateOut.Day)) : Convert.ToString(book.DateOut.Day));
            return(View(book));
        }
        public IHttpActionResult Get(string token)
        {
            var item = Repositories.GetBookingByToken(token);

            if (item != null)
            {
                var booking = new BookingView {
                    IDBooking = item.IDBooking, IDCus = item.IDCus, DateIn = item.DateIn, DateOut = item.DateOut, DayCreateBooking = item.DayCreateBooking, DurationStay = item.DurationStay, IDCateRoom = item.IDCateRoom, NumberRoom = item.NumberRoom, NewBooking = item.NewBooking, TokenBooking = item.TokenBooking, NameCus = item.Customer.NameCus, AddressCus = item.Customer.AddressCus, EmailCus = item.Customer.EmailCus, PhoneCus = item.Customer.PhoneCus, DayCreateCus = item.Customer.DayCreateCus, NameCateRoom = item.CategoryRoom.NameCateRoom, CountRoomBook = Repositories.GetRB(item.IDBooking).Count(), PriceCateRoom = item.CategoryRoom.PriceCateRoom
                };
                return(Ok(booking));
            }
            return(InternalServerError());
        }
Пример #26
0
        public void UpdateBooking(BookingView booking)
        {
            Bookings bookings = db.Bookings.Find(booking.Id);

            bookings.ServiceId       = booking.ServiceId;
            bookings.UserId          = booking.UserId;
            bookings.VehicleId       = booking.VehicleId;
            bookings.StartTime       = booking.StartTime;
            bookings.Status          = booking.Status;
            bookings.EndTime         = booking.EndTime;
            db.Entry(bookings).State = EntityState.Modified;
            db.SaveChanges();
        }
Пример #27
0
        private void OpenEventCommandExecuted()
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new BookingView(BookingViews.Event, new EventModel(EventReminder.EventReminder.Event));

            window.ShowDialog();

            if (window.DialogResult != null && window.DialogResult.Value)
            {
                var IsCurrentEventReminderDeleted = true;
                var eventBookingView      = window.ViewModel.Content as EventBookingView;
                var eventBookingViewModel = eventBookingView.ViewModel as EventBookingViewModel;
                if (eventBookingViewModel.Event.EventReminders.Where(eventReminder => eventReminder.EventReminder.ID == _eventReminder.EventReminder.ID).Count() > 0)
                {
                    IsCurrentEventReminderDeleted = false;
                }

                if (IsCurrentEventReminderDeleted)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        //var currentPopUp = Application.Current.MainWindow;
                        //var viewModel = currentPopUp.DataContext as MainWindowModel;
                        //var workspaceView = viewModel.WindowContent as WorkspaceView;
                        //var tile = workspaceView.RootTileView.MaximizedItem as Tile;
                        //if (tile.Name == "CRM")
                        //{
                        //    var crmview = tile.Content as CRMView;
                        //    var crmvm = crmview.DataContext as CRMViewModel;

                        //    if (isToDo)
                        //        crmvm.ReloadFollowUps();
                        //    else
                        //    {
                        //        crmvm.ReloadFollowUpsAndEnquiries();
                        //    }
                        //}
                    }));
                    RaisePropertyChanged("CloseParentWindow");
                }
                else
                {
                    RaisePropertyChanged("EnableParentWindow");
                }
            }
            else
            {
                RaisePropertyChanged("EnableParentWindow");
            }
        }
Пример #28
0
        public ActionResult ChangeStatus(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingView bookings = _bookingManager.GetBooking(id);

            if (bookings == null)
            {
                return(HttpNotFound());
            }
            return(View(bookings));
        }
        public ActionResult TakeRoomForm(string token)
        {
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + token).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;

            if (book.NumberRoom > book.CountRoomBook)
            {
                TempData["diff"] = book.NumberRoom - book.CountRoomBook;
            }
            HttpResponseMessage resRoom = GlobalVariables.client.GetAsync("EmptyRoom/" + book.IDCateRoom.ToString()).Result;

            TempData["room"] = resRoom.Content.ReadAsAsync <IEnumerable <RoomView> >().Result;
            return(View(book));
        }
        public ActionResult ChangeRoom(int idRB, string token)
        {
            HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + token).Result;
            BookingView         book       = resBooking.Content.ReadAsAsync <BookingView>().Result;
            HttpResponseMessage resRoom    = GlobalVariables.client.GetAsync("EmptyRoom/" + book.IDCateRoom.ToString()).Result;

            TempData["room"]   = resRoom.Content.ReadAsAsync <IEnumerable <RoomView> >().Result;
            TempData["token"]  = token;
            TempData["idBook"] = book.IDBooking;
            HttpResponseMessage resRB = GlobalVariables.client.GetAsync("RoomBooking?idRB=" + idRB.ToString()).Result;
            RoomBookingView     rb    = resRB.Content.ReadAsAsync <RoomBookingView>().Result;

            return(View(rb));
        }