Пример #1
0
        private void Save()
        {
            try
            {
                if (IsNewTable == false)
                {
                    Data.Table table = _tablesRepository.GetTableById(ManipulatedTable.Id);
                    table.Name     = ManipulatedTable.Name;
                    table.Capacity = ManipulatedTable.Capacity;

                    _tablesRepository.UpdateTable(table);
                    CancelRequested?.Invoke();
                    MessageHandler.InvokeSuccessMessage(Resources.InformationUpdateTable, Resources.InformationTableUpdated);
                }
                else
                {
                    _tablesRepository.AddTable(new Table
                    {
                        Capacity = ManipulatedTable.Capacity, Name = ManipulatedTable.Name, IsOccupied = ManipulatedTable.IsOccupied, Id = ManipulatedTable.Id
                    });

                    ToTableViewRequested?.Invoke();
                    MessageHandler.InvokeSuccessMessage(Resources.InformationAddTable, Resources.InformationTableAdded);
                }
            }

            catch (Exception e)
            {
                ErrorHandler.ThrowError(0, e.Message);
            }
        }
Пример #2
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);
            }
        }