private void EditItemCommandExecuted(EventItemModel item) { RaisePropertyChanged("DisableParentWindow"); if (item.Instance.GetType() == typeof(EventCateringModel)) { var model = (EventCateringModel)item.Instance; var window = new AddCateringItemView(Event, model, AlreadyBookedCaterings, AlreadyBookedRooms); window.ShowDialog(); if (window.DialogResult != null && window.DialogResult.Value) { AlreadyBookedCaterings.Remove(model); EventItemsAlreadyBooked.Remove(item); _event.Event.LastEditDate = DateTime.Now; _event.RefreshItems(); } } else if (item.Instance.GetType() == typeof(EventGolfModel)) { var model = (EventGolfModel)item.Instance; var window = new AddEventGolfItemView(Event, model, AlreadyBookedGolfs); window.ShowDialog(); if (window.DialogResult != null && window.DialogResult.Value) { AlreadyBookedGolfs.Remove(model); EventItemsAlreadyBooked.Remove(item); _event.Event.LastEditDate = DateTime.Now; _event.RefreshItems(); } } else if (item.Instance.GetType() == typeof(EventRoomModel)) { var model = (EventRoomModel)item.Instance; var window = new AddRoomItemView(Event, model, AlreadyBookedCaterings, AlreadyBookedRooms); window.ShowDialog(); if (window.DialogResult != null && window.DialogResult.Value) { AlreadyBookedRooms.Remove(model); EventItemsAlreadyBooked.Remove(item); _event.Event.LastEditDate = DateTime.Now; _event.RefreshItems(); } } RaisePropertyChanged("EnableParentWindow"); if (EventItemsAlreadyBooked.Count == 0) { RaisePropertyChanged("CloseDialog"); } }
private void DeleteItemCommandExecuted(EventItemModel item) { bool? dialogResult = null; string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM; RaisePropertyChanged("DisableParentWindow"); RadWindow.Confirm(new DialogParameters() { Owner = Application.Current.MainWindow, Content = confirmText, Closed = (sender, args) => { dialogResult = args.DialogResult; } }); RaisePropertyChanged("EnableParentWindow"); if (dialogResult != true) { return; } if (item.Instance.GetType() == typeof(EventCateringModel)) { var model = (EventCateringModel)item.Instance; // Remove booked products model.EventBookedProducts.ForEach(RemoveEventBookedProductAndCharges); AlreadyBookedCaterings.Remove(model); _event.EventCaterings.Remove(model); _eventsDataUnit.EventCateringsRepository.Delete(model.EventCatering); } else if (item.Instance.GetType() == typeof(EventGolfModel)) { var model = (EventGolfModel)item.Instance; // Remove booked products model.EventBookedProducts.ForEach(RemoveEventBookedProductAndCharges); if (model.EventGolf.LinkedEventGolfId != null) { if (model.EventGolf.EventGolf1 == null) { _eventsDataUnit.EventGolfsRepository.DetachGolfEvent((Guid)model.EventGolf.LinkedEventGolfId); } else { _eventsDataUnit.EventGolfsRepository.Delete(model.EventGolf.EventGolf1); } } AlreadyBookedGolfs.Remove(model); _event.EventGolfs.Remove(model); _eventsDataUnit.EventGolfsRepository.Delete(model.EventGolf); } else if (item.Instance.GetType() == typeof(EventRoomModel)) { var model = (EventRoomModel)item.Instance; // Remove booked products model.EventBookedProducts.ForEach(RemoveEventBookedProductAndCharges); AlreadyBookedRooms.Remove(model); _event.EventRooms.Remove(model); _eventsDataUnit.EventRoomsRepository.Delete(model.EventRoom); } EventItemsAlreadyBooked.Remove(item); _event.Event.LastEditDate = DateTime.Now; _event.RefreshItems(); if (EventItemsAlreadyBooked.Count == 0) { RaisePropertyChanged("CloseDialog"); } }