try
{
DateTime _LastModifiedDateTC ;
List timeSheetApprovedView = new List();
foreach (var Item in timeSheetApprovedView.TimeCards)
{
if (Item.IsStateFarm == true)
{
_LastModifiedDateTC = Global.GetTimecardLastModifiedDate(Item.TimeCardID, (int)InvoiceSourceTypes.TimeCard).GetValueOrDefault();
}
else
{
_LastModifiedDateTC = Global.GetTimecardLastModifiedDate(Item.TimeCardID, (int)InvoiceSourceTypes.PerHour).GetValueOrDefault();
}
if (Item.LastModifiedDate == _LastModifiedDateTC)
{
//how to assign values when condition matches
}
}
List StateFarmTimeCardIDs = timeSheetApprovedView.TimeCards.Where(x => x.IsStateFarm)?.Select(x => x.TimeCardID)?.ToList();
List OtherTimeCardIDs = timeSheetApprovedView.TimeCards.Where(x => !x.IsStateFarm)?.Select(x => x.TimeCardID)?.ToList();
int? BaseStateProvinceID = null; Loading
Basit NisarPosted May 5, 2023, 10:42 AM
not just StateFarmTimeCardIDs here we have OtherTimeCardIDs so anyway to add in this list timeSheetApprovedView??
Tuhin PaulPosted May 5, 2023, 8:56 AM
To assign values when the condition matches, see the code here :
In the code above, we first check if the condition Item.LastModifiedDate == _LastModifiedDateTC matches for the current item. If it does, we can then assign the values to the variables StateFarmTimeCardIDs and BaseStateProvinceID as needed.
The code above assumes that StateFarmTimeCardIDs and BaseStateProvinceID have already been declared and initialized earlier in the code. If not, you'll need to add the appropriate declarations before the foreach loop.