Ejemplo n.º 1
0
        public ActionResult LogOff()
        {
            try
            {
                ActivityString activity = LogActivity.LogoutUser();
                int.TryParse(Session["UserID"].ToString(), out int id);

                int recordID = ModelCollections.userActivityLogs.Count + 1;
                ModelCollections.userActivityLogs.Add(new UserActivityLog()
                {
                    ID                  = recordID,
                    UserAccountID       = id,
                    Username            = Session["Username"].ToString(),
                    Activity            = activity.Activity,
                    ActivityDate        = DateTime.Now,
                    ActivityDescription = activity.ActivityDescription,
                    Error               = "", //if there was an error, you can report it here as well
                    Source              = System.Environment.MachineName
                });

                Session["UserRole"] = null;
                Session["Username"] = null;
                Session["UserID"]   = null;
            }
            catch (Exception ex)
            {
                // Info
                throw ex;
            }
            // Info.
            return(this.RedirectToAction("Login", "Login"));
        }