Presenter Here I called a method called "services.UpdateSelectedDeposit(deposit);". As you can see it calls a method in the below services, which calls a method in the repository to set deposit model based on the DepositID.
public void OnDoubleClicked(object sender, EventArgs e)
{
if(addTipView.DataGridView.CurrentRow.Index != -1)
{
deposit.DepositID = Convert.ToInt32(addTipView.DataGridView.CurrentRow.Cells["DepositID"].Value);
Console.WriteLine(deposit.DepositID);
services.UpdateSelectedDeposit(deposit);
Console.WriteLine(deposit.DepositAmount);
addTipView.TxtTipAmount = deposit.DepositAmount.ToString();
addTipView.TxtDate = deposit.DepoistDate.ToString();
addTipView.TxtHoursWorked = deposit.HoursWorked.ToString();
}
}
Services
public void UpdateSelectedDeposit(Deposit deposit)
{
repo.GetSelectedDeposit(deposit);
}
Repository
public void GetSelectedDeposit(Deposit deposit)
{
using (var context = new TipManagerDBEntities())
{
deposit = context.Deposits.Where(x => x.DepositID == deposit.DepositID).FirstOrDefault();
Console.WriteLine(deposit.DepositAmount);
}
}
When I print the deposit amount in the repository I get the correct value but when I print the deposit amount in the presenter it's not correct. The deposit class I pass as an argument are passed by reference, right? Why is my value not correct in the presenter.