public static bool ResetUserOnLogout()
        {
            try
            {
                using (var model = new fmDbDataModel())
                {
                    int userId = Convert.ToInt32(HttpContext.Current.Session["USER_ID"]);

                    var userToLogout = model.fm_Users.FirstOrDefault(
                        user => user.Id == UserSingleton.Instance.Id
                        &&
                        user.Email == UserSingleton.Instance.Email);

                    userToLogout.LastSuccessfullLogin          = DateTime.Now;
                    userToLogout.IsOnline                      = (int)UserCurrentStatus.Offine;
                    model.Entry <fm_Users>(userToLogout).State = System.Data.Entity.EntityState.Modified;
                    model.SaveChanges();

                    UserSingleton.Reset();

                    HttpContext.Current.Session["USER_ID"]    = null;
                    HttpContext.Current.Session["USER_EMAIL"] = null;
                }

                return(true);
            }
            catch (Exception e)
            {
                _log.ErrorFormat("There was an error with resetting user data while loggin out. Message: {0}, Stacktrace: {1}", e.Message, e.StackTrace);
                return(false);
            }
        }
        public static bool InitializeUserLogin(fm_Users User)
        {
            try
            {
                using (var model = new fmDbDataModel())
                {
                    UserSingleton.CreateUserSingleton(User);

                    HttpContext.Current.Session["USER_ID"]    = User.Id;
                    HttpContext.Current.Session["USER_EMAIL"] = UserSingleton.Instance.Email;

                    User.LastSuccessfullLogin          = DateTime.Now;
                    User.IsOnline                      = (int)UserCurrentStatus.Online;
                    model.Entry <fm_Users>(User).State = System.Data.Entity.EntityState.Modified;
                    model.SaveChanges();
                }

                return(true);
            }
            catch (Exception e)
            {
                _log.ErrorFormat("There was an error with initializing user login. Message: {0}, Stacktrace: {1}", e.Message, e.StackTrace);
                return(false);
            }
        }