Example #1
0
        public AddCateringItemView(EventModel Event, EventCateringModel eventCatering = null, List <EventCateringModel> alreadyBookedCaterings = null, List <EventRoomModel> alreadyBookedRooms = null)
        {
            InitializeComponent();

            DataContext = _viewModel = new AddCateringItemViewModel(Event, eventCatering, alreadyBookedCaterings, alreadyBookedRooms);
            _viewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Owner = Application.Current.MainWindow;

            Loaded += OnAddCateringItemViewLoaded;
        }
        private EventCateringModel GetEventCatering()
        {
            var cateringModel = new EventCateringModel(new EventCatering
            {
                ID                      = Guid.NewGuid(),
                EventID                 = _event.Event.ID,
                StartTime               = _event.Date,
                EndTime                 = _event.Date,
                ShowInInvoice           = true,
                IncludeInCorrespondence = true,
                IncludeInForwardBook    = true
            });

            return(cateringModel);
        }
        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;
                });
            }
        }
        public AddCateringItemViewModel(EventModel eventModel, EventCateringModel cateringModel, List <EventCateringModel> alreadyBookedCaterings, List <EventRoomModel> alreadyBookedRooms)
        {
            _event = eventModel;

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

            SubmitCommand              = new RelayCommand(SubmitCommandExecuted, SubmitCommandCanExecute);
            AddItemCommand             = new RelayCommand(AddItemCommandExecuted);
            CancelCommand              = new RelayCommand(CancelCommandExecuted);
            AddProductCommand          = new RelayCommand(AddProductCommandExecuted);
            DeleteBookedProductCommand = new RelayCommand <EventBookedProductModel>(DeleteBookedProductCommandExecuted);

            AlreadyBookedCaterings = alreadyBookedCaterings;
            AlreadyBookedRooms     = alreadyBookedRooms;

            ProcessEventCatering(cateringModel);
        }
        private void AddCateringProduct(EventCateringModel model)
        {
            var charge = new EventCharge
            {
                ID            = Guid.NewGuid(),
                EventID       = _event.Event.ID,
                ShowInInvoice = model.EventCatering.ShowInInvoice
            };

            var productModel = new EventBookedProductModel(new EventBookedProduct
            {
                ID = Guid.NewGuid(),
                EventBookingItemID = model.EventCatering.ID,
                EventID            = _event.Event.ID,
                EventCharge        = charge
            });

            productModel.Quantity         = _event.Event.Places;
            productModel.PropertyChanged += OnEventBookedProductModelPropertyChanged;

            model.EventBookedProducts.Add(productModel);
        }