public bool SaveIntervalDatas(string conString)
        {
            var context = new ExcelEntities();

            try
            {
                using (OleDbConnection connExcel = new OleDbConnection(conString))
                {
                    using (OleDbCommand cmdExcel = new OleDbCommand())
                    {
                        using (OleDbDataAdapter odaExcel = new OleDbDataAdapter())
                        {
                            DataTable dt = new DataTable();
                            cmdExcel.Connection = connExcel;

                            connExcel.Open();
                            DataTable dtExcelSchema;
                            dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                            string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                            connExcel.Close();

                            connExcel.Open();
                            cmdExcel.CommandText   = "SELECT * From [" + sheetName + "]";
                            odaExcel.SelectCommand = cmdExcel;
                            odaExcel.Fill(dt);
                            connExcel.Close();

                            foreach (DataRow row in dt.Rows)
                            {
                                var id = new IntervalData
                                {
                                    DeliveryPoint = long.Parse(row.ItemArray[0].ToString()),
                                    Date          = DateTime.Parse(row.ItemArray[1].ToString()),
                                    TimeSlot      = new TimeSpan(Convert.ToInt32(row.ItemArray[2].ToString())),
                                    SlotVal       = Decimal.Parse(row.ItemArray[3].ToString())
                                };
                                context.IntervalDatas.Add(id);
                            }
                            context.SaveChanges();
                            return(true);
                        }
                    }
                }
            }
            catch
            {
                return(false);
            }
        }
        private void AddToDb(List <ExcelModel> list)
        {
            var context = new ExcelEntities();

            try
            {
                context.ExcelModels.AddRange(list);
                context.SaveChanges();
                TempData["Message"] = "Dodane";
            }
            catch (Exception ex)
            {
                TempData["Message"] = ex.Message;
            }
        }
        public IEnumerable <IntervalData> GetIntervalDatas()
        {
            var context = new ExcelEntities();

            return(context.IntervalDatas.ToList());
        }