public bool Delete(Table table)
        {
            try
            {
                _isDirty = true;
                return _tableDataService.DeleteObject(table.TableId);
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return false;
        }
        public ReservationDetailsViewModel(IUnityContainer container, ILoggerFacade logger, IReservationManager reservationManager, ITableManager tableManager, IMessageBoxService messageBoxService, IDialogBoxService dialogBoxService)
        {
            this._logger = logger;
            this._container = container;
            this._reservationManager = reservationManager;
            this._tableManager = tableManager;
            this._messageBoxService = messageBoxService;
            this._dialogBoxService = dialogBoxService;

            var allTables = this._tableManager.GetAll().ToDictionary(tbl => tbl.TableId, tbl => tbl);

            // Assumption : Reservation duration is between 10 Am and 10 Pm
            this._minFromHour = 10;
            this._maxFromHour = 22;

            this._reservedTables = new ObservableCollection<Table>();
            var currentReservation = this._container.Resolve(typeof(Reservation), "SelectedReservation");
            if (currentReservation != null)
            {
                this.FromHour = (short)(currentReservation as Reservation).TimeFrom;
                this.ToHour = (short)(currentReservation as Reservation).TimeTo;
                this._currentReservation = currentReservation as Reservation;
                this._currentReservation.PropertyChanged += _currentReservation_PropertyChanged;

                foreach (var tableId in this._currentReservation.ReservedTableIds)
                {
                    this._reservedTables.Add(allTables[tableId]);
                }

                this._availableTables = new ObservableCollection<Table>(this.GetAvailableTables((ushort)this._fromHour, (ushort)this._toHour));
                if (this._availableTables != null && this._availableTables.Count > 0)
                {
                    this._selectedAvailableTable = this._availableTables.First();
                }
            }
            else
            {
                this.FromHour = this._minFromHour;
            }

            if (this._reservedTables != null && this._reservedTables.Count > 0)
            {
                this._selectedReservedTable = this._reservedTables.First();
            }

            this.SaveCommand = new DelegateCommand(this.OnSaveCommand, () =>
            {
                return this._currentReservation != null &&
                    this._reservedTables != null &&
                    this._reservedTables.Count > 0 &&
                    !string.IsNullOrEmpty(this._currentReservation.CustomerName) &&
                    !string.IsNullOrEmpty(this._currentReservation.ContactNumber);
            });

            this.CancelCommand = new DelegateCommand(this.OnCancelCommand, () => { return this._currentReservation != null; });

            this.ReserveTableCommand = new DelegateCommand(this.OnReserveTableCommand, () =>
            {
                return this._currentReservation != null &&
                    this._selectedAvailableTable != null &&
                    this._currentReservation.NoOfPersons > this._reservedTables.Sum(tbl => tbl.MaxOccupancy);
            });

            this.UnreserveTableCommand = new DelegateCommand(this.OnUnreserveTableCommand, () =>
            {
                return this._currentReservation != null &&
                    this._selectedReservedTable != null;
            });
        }
        public bool ImportTables(string fileName)
        {
            bool returnValue = false;

            try
            {
                var xmlTables = this._tableDataService.GetXElements(fileName, "Tables", "Table");
                var tables = new List<Table>();
                foreach (var xmlTable in xmlTables)
                {
                    var table = new Table();
                    table.DisplayName = string.Format("Table - {0}", xmlTable.Attribute("Id").Value);
                    ushort maxCapacity;
                    if (ushort.TryParse(xmlTable.Attribute("MaxOccupancy").Value, out maxCapacity))
                    {
                        table.MaxOccupancy = maxCapacity;
                        tables.Add(table);
                    }
                }

                if (tables.Count > 0)
                {
                    this.SaveAll(tables);
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return returnValue;
        }