public ActionResult Schedule()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            var cellfeedlink = App.SheetFeedData;

            CellQuery cquery = new CellQuery(cellfeedlink);
            CellFeed cfeed = service.Query(cquery);

            Console.WriteLine("Cells in this worksheet:");
            uint rownum = 2;
            List<Session> sessions = new List<Session>();
            Session workingSession = new Session();

            foreach (CellEntry curCell in cfeed.Entries)
            {
                if (curCell.Cell.Row > 1)
                {
                    if (curCell.Cell.Row != rownum)
                    {
                        sessions.Add(workingSession);
                        rownum = curCell.Cell.Row;
                        workingSession = new Session();
                    }
                    switch (curCell.Cell.Column)
                    {
                        case 1:
                            workingSession.IID = int.Parse(curCell.Cell.Value);
                            break;
                        case 2:
                            workingSession.Title = curCell.Cell.Value;
                            break;
                        case 3:
                            workingSession.SpeakerDescription = curCell.Cell.Value;
                            break;
                        case 4:
                            workingSession.Description = curCell.Cell.Value;
                            break;
                        case 5:
                            workingSession.Room = curCell.Cell.Value;
                            break;
                        case 6:
                            workingSession.StartHour = int.Parse(curCell.Cell.Value);
                            break;
                        case 7:
                            workingSession.StartAMPM = curCell.Cell.Value;
                            break;
                        case 8:
                            workingSession.LengthMin = int.Parse(curCell.Cell.Value);
                            break;
                        case 9:
                            workingSession.CSSClass = curCell.Cell.Value;
                            break;
                    }
                }
            }
            sessions.Add(workingSession);
            return View(sessions);
        }
        public bool Update(Session model)
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            SpreadsheetQuery q = new SpreadsheetQuery(App.SheetFeedData);
            // Make a request to the API and get all spreadsheets.
            SpreadsheetFeed feed = service.Query(q);
            if (feed.Entries.Count == 0)
            {
                return false;
            }

            // TODO: Choose a spreadsheet more intelligently based on your
            // app's needs.
            SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
            Console.WriteLine(spreadsheet.Title.Text);

            // Get the first worksheet of the first spreadsheet.
            // TODO: Choose a worksheet more intelligently based on your
            // app's needs.
            WorksheetFeed wsFeed = spreadsheet.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

            // Fetch the cell feed of the worksheet.
            CellQuery cellQ = new CellQuery(worksheet.CellFeedLink);
            CellFeed cfeed = service.Query(cellQ);

            Console.WriteLine("Cells in this worksheet:");
            uint rownum = 2;
            List<Session> sessions = new List<Session>();
            Session workingSession = new Session();

            uint updaterow = 0;
            foreach (CellEntry curCell in cfeed.Entries)
            {
                if (curCell.Cell.Row > 1)
                {
                    if (curCell.Cell.Row != rownum)
                    {
                        sessions.Add(workingSession);
                        rownum = curCell.Cell.Row;
                        workingSession = new Session();
                    }
                    switch (curCell.Cell.Column)
                    {
                        case 1:
                            workingSession.IID = int.Parse(curCell.Cell.Value);
                            if (workingSession.IID == model.IID)
                            {
                                updaterow = curCell.Cell.Row;
                            }
                            break;
                        case 2:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.Title;
                                curCell.Update();
                            }
                            break;
                        case 3:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.SpeakerDescription;
                                curCell.Update();
                            }
                            break;
                        case 4:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.Description;
                                curCell.Update();
                            }
                            break;
                        case 5:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.Room;
                            curCell.Update();
                            }
                            break;
                        case 6:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.StartHour.ToString();
                            curCell.Update();
                            }
                            break;
                        case 7:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.StartAMPM;
                            curCell.Update();
                            }
                            break;
                        case 8:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.LengthMin.ToString();
                            curCell.Update();
                            }
                            break;
                        case 9:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.CSSClass;
                                curCell.Update();
                            }
                            break;
                    }
                }
            }
            return true;
        }
        public ActionResult EditFull(Session model)
        {
            if (ModelState.IsValid)
            {

                if (new SpreadsheetController().Update(model))
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            return View(model);
        }
        public ActionResult Edit(Session model)
        {
            if (ModelState.IsValid)
            {

                ApplicationDbContext db = new ApplicationDbContext();
                var s = db.Sessions.Where(q => q.IID == model.IID).FirstOrDefault();
                var u = db.AppUsers.Find(User.Identity.GetUserId());
                if (s == null)
                    return HttpNotFound();
                if (!u.Admin)
                    return RedirectToAction("Index", "Home");

                s.Description = model.Description;
                db.Entry(s).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return RedirectToAction("Details", "Session", new { id = model.IID });
            }

            return View(model);
        }
        static void UpdateOrCreateSession(Session workingSession)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            var s = db.Sessions.Where(q => q.IID == workingSession.IID).FirstOrDefault();
            if (s != null)
            {
                //s.Description = workingSession.Description;
                s.CSSClass = workingSession.CSSClass;
                s.LengthMin = workingSession.LengthMin;
                s.Sort = workingSession.Sort;
                s.Room = workingSession.Room;
                s.SpeakerDescription = workingSession.SpeakerDescription;
                s.StartAMPM = workingSession.StartAMPM;
                s.StartHour = workingSession.StartHour;
                s.StartMinute = workingSession.StartMinute;
                s.Title = workingSession.Title;
                s.CustomURL = workingSession.CustomURL;
                db.Entry(s).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                db.Sessions.Add(workingSession);
            }
            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges

                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                        eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                            ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        public static List<Session> AllSessions()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            CellQuery cquery = new CellQuery(App.SheetFeedData);
            CellFeed cfeed = service.Query(cquery);

            //Row1 has the header rows, so we sant to start with row2
            uint rownum = 2;

            List<Session> sessions = new List<Session>();
            Session workingSession = new Session();
            foreach (CellEntry curCell in cfeed.Entries)
            {
                if (curCell.Cell.Row > 1)
                {
                    if (curCell.Cell.Row != rownum)
                    {
                        if (!String.IsNullOrEmpty(workingSession.Title)) {

                            sessions.Add(workingSession);
                            UpdateOrCreateSession(workingSession);
                        }
                        rownum = curCell.Cell.Row;
                        workingSession = new Session();
                    }
                    switch (curCell.Cell.Column)
                    {
                        case 1:
                            workingSession.IID = int.Parse(curCell.Cell.Value);
                            break;
                        case 2:
                            workingSession.Title = curCell.Cell.Value;
                            break;
                        case 3:
                            workingSession.SpeakerDescription = curCell.Cell.Value;
                            break;
                        case 4:
                            workingSession.Sort = curCell.Cell.Value;
                            break;
                        case 5:
                            workingSession.Room = curCell.Cell.Value;
                            break;
                        case 6:
                            workingSession.StartHour = int.Parse(curCell.Cell.Value);
                            break;
                        case 7:
                            workingSession.StartAMPM = curCell.Cell.Value;
                            break;
                        case 8:
                            workingSession.LengthMin = int.Parse(curCell.Cell.Value);
                            break;
                        case 9:
                            workingSession.CSSClass = curCell.Cell.Value;
                            break;
                        case 10:
                            workingSession.CustomURL = curCell.Cell.Value;
                            break;
                        case 11:
                            int min = 0;
                            int.TryParse(curCell.Cell.Value??"0", out min);
                            workingSession.StartMinute = min.ToString().PadLeft(2,'0');
                            break;
                    }
                }
            }
            sessions.Add(workingSession);
            UpdateOrCreateSession(workingSession);

            return sessions;
        }