Skip to content

Commit

Permalink
Fix PriceChangeEventArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksanderwlodarczyk committed Apr 25, 2022
1 parent a1f7b5a commit 8c40cd3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions Shop1/ShopPresentation/PresentationModel/PriceChangeEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TP.ConcurrentProgramming.PresentationModel
{
public class PriceChangeEventArgs : EventArgs
{
public PriceChangeEventArgs(Guid id, float price)
{
Price = price;
Id = id;
}
public Guid Id { get; }
public float Price { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public WarehousePresentation(IShop shop)
Shop.PriceChanged += OnPriceChanged;
}

private void OnPriceChanged(object sender, PriceChangeEventArgs e)
private void OnPriceChanged(object sender, ShopLogic.PriceChangeEventArgs e)
{
EventHandler<PriceChangeEventArgs> handler = PriceChanged;
handler?.Invoke(this, e);
EventHandler<TP.ConcurrentProgramming.PresentationModel.PriceChangeEventArgs> handler = PriceChanged;
handler?.Invoke(this, new TP.ConcurrentProgramming.PresentationModel.PriceChangeEventArgs(e.Id, e.Price));
}

public List<FruitPresentation> GetFruits()
Expand All @@ -31,6 +31,6 @@ public List<FruitPresentation> GetFruits()
return fruits;
}

public event EventHandler<PriceChangeEventArgs> PriceChanged;
public event EventHandler<TP.ConcurrentProgramming.PresentationModel.PriceChangeEventArgs> PriceChanged;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MainWindowViewModel(ModelAbstractApi modelAbstractApi)
FruitButtonClick = new RelayCommand<Guid>((id) => FruitButtonClickHandler(id));
}

private void OnPriceChanged(object sender, PriceChangeEventArgs e)
private void OnPriceChanged(object sender, TP.ConcurrentProgramming.PresentationModel.PriceChangeEventArgs e)
{
ObservableCollection<FruitPresentation> newFruits = Fruits;
FruitPresentation fruit = newFruits.FirstOrDefault(x => x.ID == e.Id);
Expand Down

0 comments on commit 8c40cd3

Please sign in to comment.