private void OnElementSelected(PieceOfClothing obj)//Not very straightforward... { //if selected object is equal to null (for example when updating the list) we might try to put the previously selected item. if (obj == null && temporaryItem != null) { //if the previous item is on the current list then select it. if (ClothesList.Exists(x => x.Id == temporaryItem.Id)) { CurrentItem = ClothesList.Find(x => x.Id == temporaryItem.Id); } //if the previously selected item is not on the list then just display nothing. else { CurrentItem = obj; } } //if currently selected object is existing the go for it. else { CurrentItem = obj; } //notify other objects via event aggragation. PieceOfClothingChangedEvent evt = eventAggregator.GetEvent <PieceOfClothingChangedEvent>(); evt.Publish(CurrentItem); }
private bool Validate(PieceOfClothing item) { bool output = true; if (item.Name == "") { ShowMisingNameWarning = true; InvokePropertyChanged("ShowMisingNameWarning"); output = false; } else { ShowMisingNameWarning = false; InvokePropertyChanged("ShowMisingNameWarning"); } if (item.TypeId == null) { ShowMissingTypeWarning = true; InvokePropertyChanged("ShowMissingTypeWarning"); output = false; } else { ShowMissingTypeWarning = false; InvokePropertyChanged("ShowMissingTypeWarning"); } return(output); }
private bool Check(PieceOfClothing x, long typeId) { if (x.Type != null) { return(x.Type.Id == typeId); } return(false); }
/// <summary> /// Deprecated, use bool Check(PieceOfClothing x, long typeId) instead /// </summary> /// <param name="x"></param> /// <param name="name"></param> /// <returns></returns> private bool Check(PieceOfClothing x, string name) { if (x.Type != null) { return(x.Type.Name == name); } return(false); }
public ClothesEditViewModel(IEventAggregator eventAggregator, IRegionManager regionManager, IClothesServices clothesService, ITypesService typesService, PieceOfClothing pieceOfClothing) { this.eventAggregator = eventAggregator; this.regionManager = regionManager; this.clothesService = clothesService; this.typesService = typesService; CurrentItem = pieceOfClothing; Initialize(); }
private void Initialize() { Title = "Nowy przedmiot"; CurrentItem = new PieceOfClothing() { Name = "", InUse = false, PicturePath = "", TimesOn = 0 }; }
public void DeletePieceOfClothing(PieceOfClothing c) { try { clothes cl = c.Toclothes(); dbConnection.DeletePieceOfClothing(cl); } catch (Exception e) { eventAggregator.GetEvent <DatabaseConnectionErrorOccuredEvent>().Publish(e.ToString()); return; } }
public void UpdatePieceOfClothing(PieceOfClothing c) { try { clothes cl = c.Toclothes(); ImageService imageService = new ImageService(); string generatedName = imageService.SaveImage(c.PicturePath, c.Id); if (generatedName != null) { cl.picture_path = generatedName; } dbConnection.UpdateClothes(cl); } catch (Exception e) { eventAggregator.GetEvent <DatabaseConnectionErrorOccuredEvent>().Publish(e.ToString()); } }
private void OnCurrentItemChanged(PieceOfClothing obj) { CurrentItem = obj; }
//Fires when an element is passed to the edit view model. The element is saved as current item. private void OnEditElementAdded(PieceOfClothing obj) { CurrentItem = obj; }
public IClothesEditViewModel GenerateViewModel(PieceOfClothing p) { return(new ClothesEditViewModel(eventAggregator, regionManager, clothesService, typesService, p)); }
private void OnCurrentItemChanged(PieceOfClothing obj) { //Point CurrentItem property onto the new target CurrentItem = obj; }