public ActionResult ContactsTable() { DateTime myDateTime = DateTime.Now; string sqlformattedDate = myDateTime.ToString("yyyy-MM-dd hh:mm:ss.fff"); string batchName = GetBatchName(); //Creating a new Batch object ContactBatch batch = new ContactBatch(); batch.BatchName = batchName; batch.CreatedBy = "System"; batch.DateCreated = Convert.ToDateTime(sqlformattedDate); //calling the post to ContactBatch table-- int batchID = ContactDB.GetBatchID(batch); List <ContactVM> contacts = new List <ContactVM>(); contacts = (List <ContactVM>)Session["Upload"]; ContactDB.PostToDatabase(contacts, batchID); return(View(contacts)); }