public ActionResult Logoff()
        {
            DateTime   someDateTime = DateTime.Now;
            HttpCookie cookieReq    = Request.Cookies["cookieAuth"];
            string     cookieString = null;

            if (cookieReq != null)
            {
                cookieString = CryporEngine.Decrypt(cookieReq["Login"], true);
                System.Diagnostics.Debug.WriteLine(cookieString);

                HttpCookie cookie = new HttpCookie("cookieAuth");
                cookie.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(cookie);
                if (ModelState.IsValid)
                {
                    // поиск пользователя в бд
                    User user = null;
                    using (ApplicationContext db = new ApplicationContext())
                    {
                        user = db.SetUser.Where(u => u.Login == cookieString).First();
                    }
                    if (user != null)
                    {
                        using (ApplicationContext db = new ApplicationContext())
                        {
                            SessionModel date = db.SetSession.FirstOrDefault(u => u.UserId == user.Id && u.Date == someDateTime.Date);
                            if (date != null)
                            {
                                if (date.TimeUp == date.SetTimeUp)
                                {
                                    SessionModel UPSetTimeUp = db.SetSession.Where(u => u.UserId == user.Id && u.Date == someDateTime.Date).First();
                                    UPSetTimeUp.TimeOut         = someDateTime.ToLongTimeString();
                                    UPSetTimeUp.AllTime         = Convert.ToDateTime((DateTime.Parse(UPSetTimeUp.AllTime) + (DateTime.Parse(DateTime.Now.ToLongTimeString()) - DateTime.Parse(UPSetTimeUp.TimeUp))).ToString()).ToLongTimeString();
                                    UPSetTimeUp.StatusTime      = 0;
                                    db.Entry(UPSetTimeUp).State = EntityState.Modified;
                                }
                                else
                                {
                                    SessionModel UPSetTimeUp = db.SetSession.Where(u => u.UserId == user.Id && u.Date == someDateTime.Date).First();
                                    UPSetTimeUp.TimeOut         = someDateTime.ToShortTimeString();
                                    UPSetTimeUp.AllTime         = Convert.ToDateTime((DateTime.Parse(UPSetTimeUp.AllTime) + (DateTime.Parse(DateTime.Now.ToLongTimeString()) - DateTime.Parse(UPSetTimeUp.SetTimeUp))).ToString()).ToLongTimeString();
                                    UPSetTimeUp.StatusTime      = 0;
                                    db.Entry(UPSetTimeUp).State = EntityState.Modified;
                                }
                                db.SaveChanges();
                            }
                        }
                    }
                }
                FormsAuthentication.SignOut();
            }
            return(RedirectToAction("_Index", "Home"));
        }
        public void Logofff()
        {
            DateTime   someDateTime = DateTime.Now;
            HttpCookie cookieReq    = Request.Cookies["cookieAuth"];
            string     cookieString = null;

            if (cookieReq != null)
            {
                cookieString = CryporEngine.Decrypt(cookieReq["Login"], true);
            }

            System.Diagnostics.Debug.WriteLine(cookieString);

            HttpCookie cookie = new HttpCookie("cookieAuth");

            cookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(cookie);

            FormsAuthentication.SignOut();
        }