vendredi 26 février 2021

If Statements Overwriting Previous Setter

This is probably something really simple but I've tried a few things and cant get my head around how to prevent overwriting of a value in a foreach -> if statement.

I have a file which consists of Entries which have individual Entry inside of it. I am trying to set a different value for each individual Entry but currently it is setting them correctly but overwrites on each iteration.

var inputdoc = _service.ConvertToDocument(input);
var journal = _service.ConvertFromLedger(ledger);

foreach (var i in inputdoc .Body)
{
            
        foreach (var doc in journal.Entries)
        {
            doc.Entity = entityCode;

            if (doc.Entity == 23380)
            {
                if (i.Number == "VALBEU1") { doc.BankAccount = "435345345"; }
                if (i.Number == "VALBGB1") { doc.BankAccount = "324234234"; }
                if (i.Number == "VALBHU1") { doc.BankAccount = "45342123123"; }
                if (i.Number == "VALBMX1") { doc.BankAccount = "45546231"; }
                if (i.Number == "VALBSE1") { doc.BankAccount = "2344353123"; }
                if (i.Number == "VALBUS1") { doc.BankAccount = "234435645"; }
                if (i.Number == "VALBNO1") { doc.BankAccount = "234233123"; }
            }
        }
  }

So the issue is the end result of the single Entry end up having the same BankAccount value when it should be different depending on the i.Number.. so how is it that i can make it so that when I go through my Entries and set my Entry value that BankAccount number remains the same and moves onto the next Entry..sets that value and so on..

Aucun commentaire:

Enregistrer un commentaire