コード例 #1
0
        async Task ExecuteLoadReservationsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Reservations.Clear();
                var reservations = await DataStore.FindAllAsync(true);

                foreach (var reservation in reservations)
                {
                    Reservations.Add(reservation);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        public async void GetMyReservations()
        {
            if (BaseView != null && BaseView.CheckInternetConnection())
            {
                Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, true));
                var results = await mApiService.RenterBookings(Mvx.Resolve <ICacheService>().CurrentUser.UserId, DateTime.UtcNow.ToLocalTime().DateTimeToTimeStamp(), "sorting", 20, 0);

                Reservations.Clear();
                if (results != null && results.Response.Count != 0)
                {
                    foreach (var item in results.Response)
                    {
                        Reservations.Add(new ReservationItemViewModel(this)
                        {
                            Reservation = item,
                        });
                    }
                }
                Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, false));
            }
            else
            {
                Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, SharedTextSource.GetText("TurnOnInternetText")));
            }
        }
コード例 #3
0
 public void AddReservation(Reservation reservation)
 {
     reservation.ReservedApartment = Apartments.Where(a => a.IsDeleted == false && a.Id == reservation.ReservedApartment.Id).FirstOrDefault();
     reservation.Guest             = Users.Where(u => u.IsDeleted == false && u.Username == reservation.Guest.Username).FirstOrDefault() as Guest;
     Reservations.Add(reservation);
     SaveChanges();
 }
コード例 #4
0
        public void SaveReservation(ReservationInfo resInfo)
        {
            Guest       guest       = GetGuest(resInfo);
            Reservation reservation = GetReservation(resInfo.Id);

            if (reservation == null)
            {
                Reservations.Add(new Models.Reservation(resInfo));
                Logging.Instance.WriteLine("Add reservation:");

                reservation = resInfo.ToReservation(this);
                Context.Reservations.Add(reservation);
            }
            else
            {
                Reservations[resInfo.Id - 1] = new Models.Reservation(resInfo);
                Logging.Instance.WriteLine("Edit reservation:");
                Logging.Instance.WriteLine($"Old: {reservation}", true);

                UpdateReservation(reservation, guest, resInfo);
            }
            Logging.Instance.WriteLine($"New: {reservation}", true);
            Context.SaveChanges();
            UpdateResInfos();
            OnReservationsChanged?.Invoke(this, EventArgs.Empty);
        }
コード例 #5
0
ファイル: Location.cs プロジェクト: radtek/Pos
        /// <summary>
        /// Adds to locations collection of reservations, saves location's state to database.
        /// </summary>
        /// <param name="newReservation"></param>
        public void AddReservation(Reservation newReservation)
        {
            if (newReservation.ReservedList.Count == 0)
            {
                throw new ReservationException("No tables.");
            }

            if (newReservation.GuestCount < 1)
            {
                throw new ReservationException("Guest count cannot be less than one");
            }

            foreach (Table table in newReservation.ReservedList)
            {
                IList <Reservation> reservationsByTable = table.ReservationsThatUseMe;
                Reservability       availability        = this.GetReservability(reservationsByTable, table, newReservation.Arrival, null, newReservation.Duration);
                if (!availability.FullyAvailable)
                {
                    throw new ReservationException(string.Format("Reservation not added because {0} is not available.", table.ToString()));
                }
            }

            newReservation.ParentLocation = this;
            newReservation.Save();
            Reservations.Add(newReservation);

            // cascade
            this.Save();
        }
コード例 #6
0
        public BookRessourceViewModel()
        {
            proxy        = AutofacHelper.Container.Resolve <ApiClientProxy>();
            drawBookning = new DrawResourcer();
            Date         = DateTime.Now;
            StartTime    = DateTime.Now.TimeOfDay;
            SlutTime     = DateTime.Now.TimeOfDay;

            _hubConnectionRerservation = new HubConnectionBuilder()
                                         .WithUrl($"{Resources.SignalRBaseAddress}ReservationHub").Build();
            _hubConnectionRerservation.StartAsync();
            _hubConnectionResource =
                new HubConnectionBuilder().WithUrl($"{Resources.SignalRBaseAddress}ResourceHub").Build();
            _hubConnectionResource.StartAsync();

            //SignalR Client methods for Reservation
            _hubConnectionRerservation.On <Reservation>("CreateReservation", reservation =>
            {
                Reservations.Add(reservation);
                reftesh(reservation.Timeslot.FromDate.DayOfWeek);
            });
            _hubConnectionRerservation.On <Reservation>("UpdateReservation", reservation =>
            {
                Reservations[Reservations.FindIndex(r => r.Id == reservation.Id)] = reservation;
                reftesh();
            });
            _hubConnectionRerservation.On <Reservation>("DeleteReservation", reservation =>
            {
                Reservations.RemoveAt(Reservations.FindIndex(re => reservation.Id == re.Id));
                reftesh(reservation.Timeslot.FromDate.DayOfWeek);
            });

            //SignalR Client methods for Resource
            _hubConnectionResource.On <Resource>("UpdateResource", resource =>
            {
                if (resource.Id == Id)
                {
                    if (resource.TimeSlots == null)
                    {
                        TimeSlots = new List <AvailableTime>();
                        reftesh();
                    }

                    foreach (var timeslot in resource.TimeSlots)
                    {
                        if (TimeSlots.Find(r => r.Id == timeslot.Id) != null)
                        {
                            TimeSlots[TimeSlots.FindIndex(r => r.Id == timeslot.Id)] = timeslot;
                            reftesh();
                        }
                        else
                        {
                            TimeSlots.Add(timeslot);
                            reftesh();
                        }
                    }
                }
            });
        }
コード例 #7
0
 private void New()
 {
     Reservations.Add(new ReservationDto
     {
         From = DateTime.Today,
         To   = DateTime.Today
     });
 }
コード例 #8
0
ファイル: Manager.cs プロジェクト: gcrouzille/M2ICars
 public void AddReservation(Reservation r)
 {
     Reservations.Add(r);
     (((App.Current.MainWindow as MainWindow).MainFrame.Content as ReservationManagement).DataContext as ReservationViewModel).Reservations.Add(r);
     Task.Run(async() =>
     {
         await APIService.Instance.Request("POST", $"api/Reservations", r);
     });
 }
コード例 #9
0
        public void GetReservations(int id_p)
        {
            Reservations.Clear();
            var reserv = ReservationRepository.GetReservations(id_p);

            foreach (var r in reserv)
            {
                Reservations.Add(r);
            }
        }
コード例 #10
0
 /// <summary>
 /// Used to add reservation on flight
 /// </summary>
 internal void BookFlightTicket(Passenger passenger)
 {
     if (Status == FlightStatus.OpenForReservation)
     {
         Reservations.Add(new Reservation(passenger, this));
         FlightInfo?.Invoke($"{passenger.FirstName} has booked a ticket to {Destination}");
     }
     else
     {
         throw new Exception("Reservation failed, flight is full!");
     }
 }
コード例 #11
0
 public bool AddReservation(Reservation reservation, int id_p)
 {
     if (!IsReservationInDataBase(reservation))
     {
         if (ReservationRepository.AddReservation(reservation, id_p))
         {
             Reservations.Add(reservation);
             return(true);
         }
     }
     return(false);
 }
コード例 #12
0
        private void AddNewReservation()
        {
            RoomReservation r = new RoomReservation();

            r.Description       = "Describe what this reservation is for";
            r.ReservationStart  = DateTime.Now;
            r.ReservationFinish = DateTime.Now.AddHours(1);
            //DataStoreItemViewModel rvm = Application.GetLibrarian().GetViewModel(r);
            DataStoreItemViewModel rvm = new DataStoreItemViewModel(r);


            Reservations.Add(rvm);
        }
コード例 #13
0
 public bool AddReservation(Reservation reservation)
 {
     if (reservation == null)
     {
         throw new ArgumentNullException("reservation");
     }
     if (FindReservationByReservation(reservation.ID) == null)
     {
         Reservations.Add(reservation);
         return(true);
     }
     return(false);
 }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user"></param>
        /// <param name="reservable"></param>
        /// <param name="date"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public bool AddReservation(int id, int user, int reservable,
                                   DateTime date, double duration)
        {
            if (!Available(reservable, date, duration))
            {
                return(false);
            }
            Reservation toAdd = new Reservation(id, user, reservable,
                                                date, duration);

            Reservations.Add(id, toAdd);
            return(true);
        }
コード例 #15
0
        /// <summary>
        /// Adds a Reservation to the list and repo.
        /// </summary>
        private void AddReservation()
        {
            if (CurrentReservation.Client != null)
            {
                return;                                    // We don't want an empty reservation :)
            }
            if (!Reservations.Contains(CurrentReservation))
            {
                Reservations.Add(CurrentReservation);
            }
            _reservationManager.AddReservation(CurrentReservation);

            CurrentReservation = new Reservation();
        }
コード例 #16
0
        public void Update(Type t)
        {
            if (t == typeof(Movie))
            {
                var _actualMovies = _db.GetObjects <Movie>();
                Movies.Clear();

                foreach (var movie in _actualMovies)
                {
                    Movies.Add(movie);
                }
                var _actualShows = _db.GetObjects <Show>();
                RemoveFilter();
                Shows.Clear();

                foreach (var show in _actualShows)
                {
                    Shows.Add(show);
                }
                var _day = DateTime.ParseExact(_showDateFilter, "dd/MM/yyyy", null);
                ApplyDateFilter(_day);
            }
            else if (t == typeof(Show))
            {
                var _actualShows = _db.GetObjects <Show>();
                Shows.Clear();
                //   RemoveFilter();
                foreach (var show in _actualShows)
                {
                    Shows.Add(show);
                }
                var day = DateTime.ParseExact(_showDateFilter, "dd/MM/yyyy", null);
                //    ApplyDateFilter(day);
            }
            else if (t == typeof(Reservation))
            {
                var _actualReservations = _db.GetObjects <Reservation>();
                App.Current.Dispatcher.Invoke(delegate
                {
                    Reservations.Clear();

                    foreach (var reservation in _actualReservations)
                    {
                        Reservations.Add(reservation);
                    }
                });
            }
        }
コード例 #17
0
ファイル: DailyPolicy.cs プロジェクト: lserhii/RestfulBank
        public Reservation Reserve(double amount, DateTime now)
        {
            var reservationTotal = Reservations.Where(r => r.Timestamp.Date == now.Date).Sum(r => r.Amount);

            if (reservationTotal + amount <= DailyLimit)
            {
                var reservation = new Reservation(this, amount, now);

                Reservations.Add(reservation);

                return(reservation);
            }
            else
            {
                return(null);
            }
        }
コード例 #18
0
ファイル: ReservationsControl.cs プロジェクト: ashsvis/hotel
        /// <summary>
        /// Нажатие кнопки "Бронирование"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbReservationClient_Click(object sender, EventArgs e)
        {
            var frm     = new ArrivalForm(_hotel); // создаем форму
            var arrival = new Reservation(_hotel)
            {
                IdEmployee = _hotel.CurrentUser.IdEmployee
            };

            frm.Build(arrival); // создаём "пустое" заселение и заполняем контролы формы
            // показываем форму в диалоге
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                arrival = frm.Data;         // получаем измененные данные заселения
                _reservations.Add(arrival); // добавляем в список бронирования
                FillTable();                // перестраиваем таблицу
            }
        }
コード例 #19
0
        /// <summary>
        /// Adds or Edit a new reservation
        /// </summary>
        private void Save()
        {
            try
            {
                Data.Reservation reservation;

                if (!IsNewReservation)
                {
                    reservation = _reservationRepo.GetReservationById(ManipulatedReservation.ID);
                }
                else
                {
                    reservation = new Data.Reservation();
                }

                reservation.Table        = _tableRepo.GetTableById(SelectedTable.Id);
                reservation.AmountPeople = ManipulatedReservation.AmountPeople;
                reservation.LastName     = ManipulatedReservation.LastName;
                reservation.PhoneNumber  = ManipulatedReservation.PhoneNumber;
                reservation.StartTime    = ManipulatedReservation.StartTime;

                if (IsNewReservation)
                {
                    Reservations.Add(reservation);
                    _reservationRepo.AddReservation(reservation);
                    Cancel();
                    MessageHandler.InvokeSuccessMessage(Properties.Resources.Reservations, Properties.Resources.InfoReservationAdded);
                }
                else
                {
                    Reservations.Add(reservation);
                    _reservationRepo.UpdateReservation(reservation);
                    Cancel();
                    MessageHandler.InvokeSuccessMessage(Properties.Resources.Reservations, Properties.Resources.InfoReservationAdded);
                }
            }
            catch (ArgumentException e)
            {
                ErrorHandler.ThrowError(0, e.Message);
            }
            catch (Exception e)
            {
                ErrorHandler.ThrowError(0, e.Message);
            }
        }
コード例 #20
0
        private void UpdateRsvList()
        {
            Reservations.Clear();
            List <Reservation> reservations;

            using (var connection = _databaseService.Connect())
                reservations = connection.Reservations.Where(w => w.IsEnabled)
                               .Include(w => w.KeywordReservation)
                               .Include(w => w.SeriesReservation.Series.Episodes)
                               .Include(w => w.SlotReservation.Slot)
                               .Include(w => w.SlotReservation2)
                               .Include(w => w.TimeReservation)
                               .ToList();
            foreach (var reservation in reservations)
            {
                Reservations.Add(new ReservationItemViewModel(new ReservationItem(reservation)));
            }
        }
        private void AddInitialData(Traveler traveler)
        {
            var seattle = Locations.FindBy(l => l.City == "Seattle").First();
            var paris   = Locations.FindBy(l => l.City == "Paris").First();
            var rome    = Locations.FindBy(l => l.City == "Rome").First();
            var newYork = Locations.FindBy(l => l.City == "New York").First();

            var now = DateTime.Now;

            Reservations.Add(CreateReservation(traveler, seattle, newYork, now, "1111"));
            Reservations.Add(CreateReservation(traveler, rome, newYork, now.AddDays(-36), "2222"));
            Reservations.Add(CreateReservation(traveler, paris, rome, now.AddDays(-29), "3333"));
            Reservations.Add(CreateReservation(traveler, newYork, rome, now.AddDays(-22), "4444"));
            Reservations.Add(CreateReservation(traveler, rome, seattle, now.AddDays(-15), "5555"));
            Reservations.Add(CreateReservation(traveler, seattle, paris, now.AddDays(-8), "6666"));
            Reservations.Add(CreateReservation(traveler, newYork, paris, now.AddDays(29), "7777"));

            Reservations.Save();
        }
コード例 #22
0
        public Room WithReservation(string personName, DateTime arrival, int nights = 1)
        {
            if (nights < 1)
            {
                throw new ArgumentException("A person must stay at least 1 night");
            }

            if (string.IsNullOrEmpty(personName))
            {
                throw new ArgumentNullException(nameof(personName));
            }

            for (var i = 1; i <= nights; i++)
            {
                Reservations.Add(new Reservation(arrival.AddDays(i - 1), this, personName));
            }

            return(this);
        }
コード例 #23
0
        /// <summary>
        /// Adds a Reservation to the list and repo.
        /// </summary>
        public void AddReservation()
        {
            if (ReservationInfo == null)
            {
                CreateReservationInfo();
            }

            var reservation = new Reservation(CurrentClient, CurrentCar, ReservationInfo);

            this.CurrentReservation = reservation;
            if (CurrentReservation.Client == null)
            {
                return;                                    // We don't want an empty reservation :)
            }
            if (!Reservations.Contains(CurrentReservation))
            {
                Reservations.Add(CurrentReservation);
            }
            _reservationManager.AddReservation(CurrentReservation);
        }
コード例 #24
0
        async Task ExecuteRefreshCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            try
            {
                await CloudService.SyncOfflineCacheAsync();

                var identity = await CloudService.GetIdentityAsync();

                if (identity != null)
                {
                    var name             = identity.UserClaims.FirstOrDefault(c => c.Type.Equals("urn:microsoftaccount:name")).Value;
                    var reservationTable = await CloudService.GetTableAsync <Reservation>();

                    var reservationList = await reservationTable.ReadAllReservationsAsync();

                    Reservations.Clear();
                    foreach (var reservation in reservationList)
                    {
                        if (reservation.User == name)
                        {
                            Reservations.Add(reservation);
                            SortReservations(Reservations, reservation);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[ReservationListViewModel] Error loading items: {ex.Message}");
            }
            finally
            {
                IsBusy = false;
            }
        }
        public HttpResponseMessage Post([FromBody] ReservationDTO reservation)
        {
            // be availabe on the database before you persist the reservation. note that these schdules
            // might already be persisted if several consequent calls were made.
            // saving the new order to the database
            Reservation newReservation = reservation.FromReservationDTO();

            // newReservation.ConfirmationCode = confirmationCode;
            Reservations.Add(newReservation);
            Reservations.Save();


            // creating the response, with three key features:
            // 1. the newly saved entity
            // 2. 201 Created status code
            // 3. Location header with the location of the new resource
            var response = Request.CreateResponse(HttpStatusCode.Created, newReservation);

            response.Headers.Location = new Uri(Request.RequestUri, newReservation.ReservationId.ToString());
            return(response);
        }
コード例 #26
0
        protected override void Load()
        {
            Reservations.Clear();

            Customers.Clear();
            Cars.Clear();

            foreach (CustomerDto Customer in Service.Customers)
            {
                Customers.Add(Customer);
            }
            foreach (CarDto Car in Service.Cars)
            {
                Cars.Add(Car);
            }
            foreach (ReservationDto reservation in Service.Reservations)
            {
                Reservations.Add(reservation);
            }
            SelectedReservation = Reservations.FirstOrDefault();
        }
コード例 #27
0
        /// <summary>
        /// 预定
        /// </summary>
        /// <param name="subject">预定主题</param>
        /// <param name="from">时间区间起</param>
        /// <param name="to">时间区间止</param>
        /// <returns></returns>
        public virtual TReservation Reserve(string subject, DateTime from, DateTime to)
        {
            Check.NotNullOrWhiteSpace(subject, nameof(subject));

            TReservation newReservation = (TReservation)Activator.CreateInstance(typeof(TReservation), subject, new TimeRange(from, to), ResourceCode);

            var reservations = Reservations.Where(r => r.ReservationTime.To > Clock.Now).ToList();

            if (reservations.Any())
            {
                if (GetIfTheseReservationsConflict(newReservation, reservations))
                {
                    ThrowIfTheseReservationsConflict();
                }
            }

            Reservations.Add(newReservation);

            DomainEvents.Add(GetReserveSuccessEventData(newReservation));

            return(newReservation);
        }
コード例 #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user">person requesting reservation</param>
        /// <param name="startDate">start date</param>
        /// <param name="endDate">end date</param>
        /// <param name="price">total pay</param>
        /// <param name="roomNo">Requested room</param>
        /// <param name="hotel">Requested hotel</param>
        /// <returns>transaction status</returns>
        public bool makeRezervation(User user, DateTime startDate, DateTime endDate, double price, int roomNo)
        {
            List <Reservation> rez = new List <Reservation>();

            //I have reached the Reservations in the desired room in the hotel
            foreach (Reservation r in Reservations)
            {
                if (r.roomNo == roomNo)
                {
                    rez.Add(r);
                }
            }

            if (rez.Count == 0)
            {
                Reservations.Add(new Reservation(user, startDate, endDate, price, roomNo, Name));
                return(true);
            }

            //conformity check of desired date range
            TimeSpan timeSpan = endDate - startDate;

            if (timeSpan.TotalDays <= 0)
            {
                return(false);
            }

            foreach (Reservation r in rez)
            {
                if (r.startDate.Date <= endDate.Date && r.startDate.Date >= startDate.Date ||
                    startDate.Date <= r.endDate.Date && startDate.Date >= r.startDate.Date)
                {
                    return(false);
                }
            }

            Reservations.Add(new Reservation(user, startDate, endDate, price, roomNo, Name));
            return(true);
        }
コード例 #29
0
        public void MarkAsPaid()
        {
            SelectedAppointment.IsRunning = true;
            parentView.RunAsynchronousOperation(delegate
            {
                try
                {
                    PaymentBasketDTO basket = new PaymentBasketDTO();
                    PaymentDTO payment      = new PaymentDTO();
                    payment.Product         = SelectedReservation.Reservation;
                    payment.Count           = 1;
                    payment.Price           = SelectedReservation.Reservation.Price;
                    basket.Payments.Add(payment);
                    basket.TotalPrice = payment.Price;
                    basket            = ServiceManager.PaymentBasketOperation(basket);

                    var newReservation = new ScheduleEntryReservationViewModel((ScheduleEntryReservationDTO)basket.Payments[0].Product);
                    parentView.SynchronizationContext.Send(delegate
                    {
                        SelectedAppointment.IsRunning = false;
                        Reservations.Remove(SelectedReservation);
                        Reservations.Add(newReservation);
                        SelectedReservation = newReservation;
                    }, null);
                }
                catch (Exception ex)
                {
                    parentView.SynchronizationContext.Send(
                        delegate
                    {
                        SelectedAppointment.IsRunning = false;
                        ExceptionHandler.Default.Process(ex, "Exception_ScheduleEntriesDesignViewModel_MarkAsPaid".TranslateInstructor(), ErrorWindow.EMailReport);
                    }, null);
                }
            });
        }
コード例 #30
0
ファイル: Show.cs プロジェクト: JanJPK/S5-IO
 public Reservation AddReservation(PersonalData personalData, Tuple <int, int> seat)
 {
     return(Reservations.Add(personalData, this, seat));
 }