protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string Card = (Request.Params["Card"]);
DateTime Date = DateTime.Parse(Request.Params["Date"]);
using ( AttendanceContext db = new AttendanceContext())
{
lblEmpName.Text = db.users.Where(t => t.Card == Card).SingleOrDefault().EmployeeName;
lblDate.Text = Date.ToString("dd/MM/yyyy");
if (lblEmpName.Text == null)
{
lblEmpName.Text = "No Data";
}
if (lblDate.Text == null)
{
lblDate.Text = "No Date";
}
var firstArray = db.TimeoutJustification.Where(x => x.Date == Date && x.Card == Card && x.GeneralJustification != null).ToList();
var SecondArray = GetTimeOutData(Card, Date).OrderByDescending(t => t.Date).ToList();
///This is where i need to check both arrays
var filtered = firstArray.Except(SecondArray);
//var d = newTimeoutdata.Where(t => !newTimeoutdata.Contains(t.TimeOut.ToString())).ToList();
if(filtered!=null){
//This is where i will insert the unmatched array
db.TimeoutJustification.AddRange(filtered);
db.SaveChanges();
}
}
}
}
}
My first array contains 3 items that are identical to 3 of the items in my second array.
I need to get the 4th unmatched item from my second array only. keep in mind that I need to compare both arrays a using datetime TimeOut
since date and card will always be the same in all arrays