Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)

        {
            try
            {
                ModelCollections.userAccounts.RemoveAt(id);

                //log user activity
                //any logger can be used as well, this a custom example
                //adds data to a collection, this can be written to db directly or to a log file
                ActivityString activity = LogActivity.DeleteUser();
                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
                });

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }