Ejemplo n.º 1
0
        public static User[] GetAllUsers()
        {
            List <User> users = UserPersistence.GetAllUsers();

            if (users != null)
            {
                return(UserPersistence.GetAllUsers().ToArray());
            }
            else
            {
                return(new User[0]);
            }
        }
Ejemplo n.º 2
0
        public ActionResult ResetPassword(string UserId)
        {
            string password = UserPersistence.ResetPassword(UserId.Replace("'", "&apos;"));

            if (password != null)
            {
                ViewBag.message = UserId + "'s password has changed. New password is: " + password;
            }
            else
            {
                ViewBag.message = "There was a problem with transaction. Please try again.";
            }
            return(View("ResetUserPassword", UserPersistence.GetAllUsers()));
        }
Ejemplo n.º 3
0
        public ActionResult ChangeStatus(string Status, string UserId)
        {
            bool result = UserPersistence.ChangeUserStatus(UserId.Replace("'", "&apos;"), Status.Replace("'", "&apos;"));

            if (result)
            {
                ViewBag.message = "Transaction Completed.";
            }
            else
            {
                ViewBag.message = "Transaction Failed. Try Again.";
            }
            return(View("ChangeUserStatus", UserPersistence.GetAllUsers()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculates the statistics and puts them into the array.
        /// </summary>
        /// <returns>An integer of length 5 which contains the count of count of the number of users (total, active, and inactive), records,
        ///and comments, in this order.
        ///</returns>
        public static int[] GetStatistics()
        {
            int[] stats = new int[5];
            for (int i = 0; i < 5; i++)
            {
                stats[i] = 0;
            }
            User[]     users = UserPersistence.GetAllUsers();
            List <Car> cars  = CarPersistence.GetAllCars();

            for (int i = 0; i < users.Length; i++) // Counts for the users that are active, inactive and total.
            {
                if (users[i].status == "A")
                {
                    stats[1]++;
                }
                else
                {
                    stats[2]++;
                }
                stats[0]++;
            }

            for (int i = 0; i < cars.Count; i++) // Counts the cars in the database.
            {
                stats[3]++;
            }

            List <Comment> comments = CommentPersistence.GetAllComments();

            for (int i = 0; i < comments.Count; i++) // Counts the comments in the system.
            {
                stats[4]++;
            }
            return(stats);
        }
Ejemplo n.º 5
0
 public ActionResult ResetUserPassword()
 {
     return(View(UserPersistence.GetAllUsers()));
 }
Ejemplo n.º 6
0
 public ActionResult ChangeUserStatus()
 {
     return(View(UserPersistence.GetAllUsers()));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Lists all users that are registered to the website.
 /// </summary>
 /// <returns>View that contains all users.</returns>
 public ActionResult ListUsers()
 {
     return(View(UserPersistence.GetAllUsers()));
 }