Exemple #1
0
        public EventCateringModel(EventCatering eventCatering)
        {
            _eventCatering      = eventCatering;
            EventBookedProducts = new ObservableCollection <EventBookedProductModel>();

            _room = _eventCatering.Room;
        }
        public void CancelCommandExecuted()
        {
            _eventDataUnit.RevertChanges();

            if (_isEditMode)
            {
                MapChangedDataAfterRefresh(EventCatering.EventCatering, EventCateringOriginal.EventCatering);
                EventCatering.Room = Rooms.FirstOrDefault(p => p.ID == EventCateringOriginal.Room.ID);
                EventCatering.Refresh();
            }
        }
 private void MapChangedDataAfterRefresh(EventCatering eventCateringOriginal, EventCatering eventCateringChanged)
 {
     eventCateringOriginal.Time                    = eventCateringChanged.Time;
     eventCateringOriginal.RoomID                  = eventCateringChanged.RoomID;
     eventCateringOriginal.StartTime               = eventCateringChanged.StartTime;
     eventCateringOriginal.EndTime                 = eventCateringChanged.EndTime;
     eventCateringOriginal.Notes                   = eventCateringChanged.Notes;
     eventCateringOriginal.ShowInInvoice           = eventCateringChanged.ShowInInvoice;
     eventCateringOriginal.IncludeInForwardBook    = eventCateringChanged.IncludeInForwardBook;
     eventCateringOriginal.IncludeInCorrespondence = eventCateringChanged.IncludeInCorrespondence;
     eventCateringOriginal.IsSpecial               = eventCateringChanged.IsSpecial;
 }
        private void ProcessEventCatering(EventCateringModel cateringModel)
        {
            _isEditMode = (cateringModel != null);

            EventCatering = cateringModel ?? GetEventCatering();
            if (_isEditMode)
            {
                CreateClockItems();
                EventCateringOriginal = EventCatering.Clone();
            }
            EventCatering.PropertyChanged += OnEventBookedProductModelPropertyChanged;
            if (_isEditMode)
            {
                cateringModel.EventBookedProducts.ForEach(product =>
                {
                    product.PropertyChanged += OnEditBookedProductModelPropertyChanged;
                });
            }
        }
        private async void SubmitCommandExecuted()
        {
            SetLoadingIndicator(true);
            if (EventCatering.HasErrors)
            {
                SetLoadingIndicator(false);
                return;
            }
            EventCatering.EventCatering.Event = _event.Event;
            var eventCatering = EventCatering.Clone();

            _eventDataUnit.EventRoomsRepository.Refresh(RefreshMode.ClientWins);
            var rooms = await _eventDataUnit.EventRoomsRepository.GetAllAsync(eRoom =>
                                                                              !eRoom.Event.IsDeleted &&
                                                                              eRoom.EventID != _event.Event.ID &&
                                                                              eRoom.Event.Date == _event.Event.Date &&
                                                                              eRoom.RoomID == EventCatering.Room.ID);

            rooms = _eventDataUnit.EventRoomsRepository.SetRoomsCurrentValues(rooms).ToList();
            var eventRooms = rooms.Select(x => new EventRoomModel(x)).ToList();

            if (AlreadyBookedRooms != null)
            {
                AlreadyBookedRooms.ForEach(alreadyBookedItem =>
                {
                    eventRooms.RemoveAll(p => p.EventRoom.ID == alreadyBookedItem.EventRoom.ID);
                });
            }

            _eventDataUnit.EventCateringsRepository.Refresh(RefreshMode.ClientWins);
            var caterings = await _eventDataUnit.EventCateringsRepository.GetAllAsync(eCatering =>
                                                                                      !eCatering.Event.IsDeleted &&
                                                                                      eCatering.EventID != _event.Event.ID &&
                                                                                      eCatering.Event.Date == _event.Event.Date &&
                                                                                      eCatering.RoomID == EventCatering.Room.ID
                                                                                      );

            caterings = _eventDataUnit.EventCateringsRepository.SetCateringsCurrentValues(caterings).ToList();
            var eventCaterings = caterings.Select(x => new EventCateringModel(x)).ToList();

            if (AlreadyBookedCaterings != null)
            {
                AlreadyBookedCaterings.ForEach(alreadyBookedItem => eventCaterings.RemoveAll(p => p.EventCatering.ID == alreadyBookedItem.EventCatering.ID));
            }
            eventCaterings.RemoveAll(x => x.EventCatering.ID == _eventCatering.EventCatering.ID);

            var bookingService = new BookingsService {
                BookedRooms = eventRooms, BookedCaterings = eventCaterings
            };

            MapChangedDataAfterRefresh(EventCatering.EventCatering, eventCatering.EventCatering);

            var startTime = new DateTime(_event.Date.Year, _event.Date.Month, _event.Date.Day, _eventCatering.StartTime.Hour, _eventCatering.StartTime.Minute, 0);
            var endTime   = new DateTime(_event.Date.Year, _event.Date.Month, _event.Date.Day, _eventCatering.EndTime.Hour, _eventCatering.EndTime.Minute, 0);

            bool bookingAllowed = bookingService.IsRoomAvailable(_event.Event.ID, EventCatering.Room, startTime, endTime);

            if (!bookingAllowed && EventCatering.Room.MultipleBooking)
            {
                bool?  dialogResult = null;
                string confirmText  = Resources.MESSAGE_ROOM_IS_BOOKED_BUT_SOPPORTS_MULTIBOOKING;

                RadWindow.Confirm(new System.Windows.Controls.TextBlock {
                    Text = confirmText, TextWrapping = TextWrapping.Wrap, Width = 400
                },
                                  (s, args) => { dialogResult = args.DialogResult; });

                if (dialogResult != true)
                {
                    SetLoadingIndicator(false);
                    return;
                }

                bookingAllowed = true;
            }

            if (bookingAllowed && EventCatering.HasValidProducts)
            {
                if (!_isEditMode)
                {
                    _event.EventCaterings.Add(EventCatering);

                    _eventDataUnit.EventCateringsRepository.Add(EventCatering.EventCatering);

                    foreach (var product in EventCatering.EventBookedProducts)
                    {
                        product.EventCharge.EventCharge.ShowInInvoice = EventCatering.EventCatering.ShowInInvoice;
                        _event.EventCharges.Add(product.EventCharge);
                        _eventDataUnit.EventChargesRepository.Add(product.EventCharge.EventCharge);

                        _event.EventBookedProducts.Add(product);
                        _eventDataUnit.EventBookedProductsRepository.Add(product.EventBookedProduct);
                    }
                }
                else
                {
                    EventCatering.EventBookedProducts.ForEach(eventBookedProduct =>
                    {
                        eventBookedProduct.EventCharge.EventCharge.ShowInInvoice = EventCatering.EventCatering.ShowInInvoice;
                    });
                    var newProdcuts = _eventCatering.EventBookedProducts.Except(_event.EventBookedProducts).ToList();
                    if (newProdcuts.Any())
                    {
                        foreach (var product in newProdcuts)
                        {
                            _event.EventBookedProducts.Add(product);
                            _eventDataUnit.EventBookedProductsRepository.Add(product.EventBookedProduct);

                            _event.EventCharges.Add(product.EventCharge);
                            _eventDataUnit.EventChargesRepository.Add(product.EventCharge.EventCharge);
                        }
                    }
                }

                RaisePropertyChanged("CloseDialog");
            }
            else
            {
                RaisePropertyChanged("DisableParentWindow");

                string confirmText = Resources.MESSAGE_ROOM_IS_BOOKED;

                RadWindow.Alert(new DialogParameters
                {
                    Owner   = Application.Current.MainWindow,
                    Content = confirmText,
                });
                SetLoadingIndicator(false);
                RaisePropertyChanged("EnableParentWindow");
            }
        }
Exemple #6
0
        private async void OKCommandExecuted()
        {
            IsBusy = true;

            var fromEvent = SelectedEvent;

            await LoadLightEventDetails(fromEvent);

            // Event Caterings
            if (fromEvent.EventCaterings.Any())
            {
                fromEvent.EventCaterings.ForEach(x =>
                {
                    var catering = new EventCatering()
                    {
                        ID                      = Guid.NewGuid(),
                        EventID                 = _event.Event.ID,
                        Event                   = _event.Event,
                        Time                    = x.EventCatering.Time,
                        RoomID                  = x.EventCatering.RoomID,
                        StartTime               = x.EventCatering.StartTime,
                        EndTime                 = x.EventCatering.EndTime,
                        Notes                   = x.EventCatering.Notes,
                        ShowInInvoice           = x.EventCatering.ShowInInvoice,
                        IncludeInForwardBook    = x.EventCatering.IncludeInForwardBook,
                        IncludeInCorrespondence = x.EventCatering.IncludeInCorrespondence,
                        IsSpecial               = x.EventCatering.IsSpecial
                    };

                    var products = fromEvent.EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == x.EventCatering.ID).ToList();

                    if (products.Any())
                    {
                        products.ForEach(y =>
                        {
                            var product = new EventBookedProduct()
                            {
                                ID                 = Guid.NewGuid(),
                                EventID            = _event.Event.ID,
                                ProductID          = y.EventBookedProduct.ProductID,
                                Product            = y.EventBookedProduct.Product,
                                EventBookingItemID = catering.ID,
                                Quantity           = _event.Event.Places,
                                Price              = y.EventBookedProduct.Price
                            };

                            var charge = new EventCharge()
                            {
                                ID            = product.ID,
                                EventID       = _event.Event.ID,
                                ProductID     = product.ProductID,
                                Quantity      = product.Quantity,
                                Price         = product.Price,
                                Product       = product.Product,
                                ShowInInvoice = catering.ShowInInvoice
                            };

                            product.EventCharge = charge;


                            _eventsDataUnit.EventBookedProductsRepository.Add(product);
                            _eventsDataUnit.EventChargesRepository.Add(charge);
                            _event.EventBookedProducts.Add(new EventBookedProductModel(product));
                            _event.EventCharges.Add(new EventChargeModel(charge));
                        });
                    }
                    _eventsDataUnit.EventCateringsRepository.Add(catering);
                    _event.EventCaterings.Add(new EventCateringModel(catering));
                });
            }

            // Event Rooms
            if (fromEvent.EventRooms.Any())
            {
                fromEvent.EventRooms.ForEach(x =>
                {
                    var room = new EventRoom()
                    {
                        ID                      = Guid.NewGuid(),
                        EventID                 = _event.Event.ID,
                        Event                   = _event.Event,
                        RoomID                  = x.EventRoom.RoomID,
                        StartTime               = x.EventRoom.StartTime,
                        EndTime                 = x.EventRoom.EndTime,
                        Notes                   = x.EventRoom.Notes,
                        ShowInInvoice           = x.EventRoom.ShowInInvoice,
                        IncludeInForwardBook    = x.EventRoom.IncludeInForwardBook,
                        IncludeInCorrespondence = x.EventRoom.IncludeInCorrespondence,
                    };

                    var products = fromEvent.EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == x.EventRoom.ID).ToList();

                    if (products.Any())
                    {
                        products.ForEach(y =>
                        {
                            var product = new EventBookedProduct()
                            {
                                ID                 = Guid.NewGuid(),
                                EventID            = _event.Event.ID,
                                ProductID          = y.EventBookedProduct.ProductID,
                                Product            = y.EventBookedProduct.Product,
                                EventBookingItemID = room.ID,
                                Quantity           = _event.Event.Places,
                                Price              = y.EventBookedProduct.Price
                            };

                            var charge = new EventCharge()
                            {
                                ID            = product.ID,
                                EventID       = _event.Event.ID,
                                ProductID     = product.ProductID,
                                Quantity      = product.Quantity,
                                Price         = product.Price,
                                Product       = product.Product,
                                ShowInInvoice = room.ShowInInvoice
                            };
                            product.EventCharge = charge;

                            _eventsDataUnit.EventBookedProductsRepository.Add(product);
                            _eventsDataUnit.EventChargesRepository.Add(charge);
                            _event.EventBookedProducts.Add(new EventBookedProductModel(product));
                            _event.EventCharges.Add(new EventChargeModel(charge));
                        });
                    }
                    _eventsDataUnit.EventRoomsRepository.Add(room);
                    _event.EventRooms.Add(new EventRoomModel(room));
                });
            }

            // Event Golfs
            var fromEventGolfs = fromEvent.EventGolfs.Where(eventGolf => !eventGolf.EventGolf.IsLinked);

            if (fromEventGolfs.Any())
            {
                fromEvent.EventGolfs.ForEach(x =>
                {
                    var golf = new EventGolf()
                    {
                        ID                      = Guid.NewGuid(),
                        EventID                 = _event.Event.ID,
                        Event                   = _event.Event,
                        Time                    = x.EventGolf.Time,
                        TeeID                   = x.EventGolf.TeeID,
                        HoleID                  = x.EventGolf.HoleID,
                        Slots                   = x.EventGolf.Slots,
                        Notes                   = x.EventGolf.Notes,
                        ShowInInvoice           = x.EventGolf.ShowInInvoice,
                        IncludeInForwardBook    = x.EventGolf.IncludeInForwardBook,
                        IncludeInCorrespondence = x.EventGolf.IncludeInCorrespondence,
                        EventGolf1              = x.EventGolf.EventGolf1 != null ? new EventGolf()
                        {
                            ID                      = Guid.NewGuid(),
                            EventID                 = _event.Event.ID,
                            Event                   = _event.Event,
                            Time                    = x.EventGolf.EventGolf1.Time,
                            TeeID                   = x.EventGolf.EventGolf1.TeeID,
                            HoleID                  = x.EventGolf.EventGolf1.HoleID,
                            Slots                   = x.EventGolf.EventGolf1.Slots,
                            Notes                   = x.EventGolf.EventGolf1.Notes,
                            ShowInInvoice           = x.EventGolf.EventGolf1.ShowInInvoice,
                            IncludeInForwardBook    = x.EventGolf.EventGolf1.IncludeInForwardBook,
                            IncludeInCorrespondence = x.EventGolf.EventGolf1.IncludeInCorrespondence,
                            IsLinked                = true
                        } : null
                    };

                    var products = fromEvent.EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == x.EventGolf.ID).ToList();

                    if (products.Any())
                    {
                        products.ForEach(y =>
                        {
                            var product = new EventBookedProduct()
                            {
                                ID                 = Guid.NewGuid(),
                                EventID            = _event.Event.ID,
                                ProductID          = y.EventBookedProduct.ProductID,
                                Product            = y.EventBookedProduct.Product,
                                EventBookingItemID = golf.ID,
                                Quantity           = _event.Event.Places,
                                Price              = y.EventBookedProduct.Price
                            };

                            var charge = new EventCharge()
                            {
                                ID            = product.ID,
                                EventID       = _event.Event.ID,
                                ProductID     = product.ProductID,
                                Product       = product.Product,
                                Quantity      = product.Quantity,
                                Price         = product.Price,
                                ShowInInvoice = golf.ShowInInvoice
                            };
                            product.EventCharge = charge;
                            _eventsDataUnit.EventBookedProductsRepository.Add(product);
                            _eventsDataUnit.EventChargesRepository.Add(charge);
                            _event.EventBookedProducts.Add(new EventBookedProductModel(product));
                            _event.EventCharges.Add(new EventChargeModel(charge));
                        });
                    }
                    _eventsDataUnit.EventGolfsRepository.Add(golf);
                    _event.EventGolfs.Add(new EventGolfModel(golf));
                });
            }

            // Event Invoices
            if (fromEvent.EventInvoices.Any())
            {
                fromEvent.EventInvoices.ForEach(x =>
                {
                    var invoice = new EventInvoice()
                    {
                        ID                      = Guid.NewGuid(),
                        EventID                 = _event.Event.ID,
                        Event                   = _event.Event,
                        Notes                   = x.EventInvoice.Notes,
                        ShowInInvoice           = x.EventInvoice.ShowInInvoice,
                        IncludeInForwardBook    = x.EventInvoice.IncludeInForwardBook,
                        IncludeInCorrespondence = x.EventInvoice.IncludeInCorrespondence,
                    };

                    var products = fromEvent.EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == x.EventInvoice.ID).ToList();

                    if (products.Any())
                    {
                        products.ForEach(y =>
                        {
                            var product = new EventBookedProduct()
                            {
                                ID                 = Guid.NewGuid(),
                                EventID            = _event.Event.ID,
                                ProductID          = y.EventBookedProduct.ProductID,
                                Product            = y.EventBookedProduct.Product,
                                EventBookingItemID = invoice.ID,
                                Quantity           = _event.Event.Places,
                                Price              = y.EventBookedProduct.Price
                            };

                            var charge = new EventCharge()
                            {
                                ID            = product.ID,
                                EventID       = _event.Event.ID,
                                ProductID     = product.ProductID,
                                Product       = product.Product,
                                Quantity      = product.Quantity,
                                Price         = product.Price,
                                ShowInInvoice = invoice.ShowInInvoice
                            };
                            product.EventCharge = charge;
                            _eventsDataUnit.EventBookedProductsRepository.Add(product);
                            _eventsDataUnit.EventChargesRepository.Add(charge);
                            _event.EventBookedProducts.Add(new EventBookedProductModel(product));
                            _event.EventCharges.Add(new EventChargeModel(charge));
                        });
                    }
                    _eventsDataUnit.EventInvoicesRepository.Add(invoice);
                    _event.EventInvoices.Add(new EventInvoiceModel(invoice));
                });
            }
            RaisePropertyChanged("CloseDialog");
            IsBusy = false;
        }