public ActionResult AddUser(UserPurchase userPurchase)
        {
            UserRepository userRepository = new UserRepository();

            if (ModelState.IsValid)
            {
                var salt = "ururu";

                userPurchase.Password = UserRepository.HashPassword(userPurchase.Password.Trim(), salt);
                userPurchase.PasswordSalt = salt;
                userPurchase.Email = userPurchase.Email.ToLower().Trim();
                if (userPurchase.ActivatorsEmail != null)
                {
                    userPurchase.ActivatorsEmail = userPurchase.ActivatorsEmail.ToLower().Trim();
                }

                userPurchase.DateOfPurchase = DateTime.Now;
                userPurchase.UserRegistrationDate = DateTime.Now;

                //Check to make sure the combination of Email, Password, and Facilty is unique
                int existingUserCheck = _context.UserPurchases.Where(x => x.Email == userPurchase.Email && x.Password == userPurchase.Password && x.FacilityName == userPurchase.FacilityName).Count();

                if (existingUserCheck == 0)
                {
                    _context.UserPurchases.Add(userPurchase);
                    _context.SaveChanges();
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("Email", "The combination of Email, Password, and Facility Name must be unique. ");
                }
            }

            return View(userPurchase);
        }
        public ActionResult EditUser(UserPurchase userPurchase)
        {
            UserPurchase temp = _context.UserPurchases.First(x => x.Id == userPurchase.Id);
            UserRepository userRepository = new UserRepository();

            if (ModelState.IsValid)
            {
                String oldPassword = temp.Password;

                var salt = "ururu";
                var pw = UserRepository.HashPassword(userPurchase.Password.Trim(), salt);

                //If password changed
                if (userPurchase.Password != oldPassword)
                {
                    temp.Password = pw;
                    temp.PasswordSalt = salt;
                }

                temp.UserRegistrationDate = DateTime.Now;
                temp.UserExpirationDate = userPurchase.UserExpirationDate;
                temp.ActivatorsEmail = User.Identity.Name;
                temp.Name = userPurchase.Name;
                temp.Email = userPurchase.Email.ToLower().Trim();
                if (userPurchase.ActivatorsEmail != null)
                {
                    temp.ActivatorsEmail = userPurchase.ActivatorsEmail.ToLower().Trim();
                }
                else
                {
                    temp.ActivatorsEmail = null;
                }
                temp.FacilityName = userPurchase.FacilityName;
                temp.IsAdmin = userPurchase.IsAdmin;

                //Check to make sure the combination of Email, Password, and Facilty is unique
                int existingUserCheck = _context.UserPurchases.Where(x => x.Email == userPurchase.Email && x.Password == pw && x.FacilityName == userPurchase.FacilityName && x.Id != userPurchase.Id).Count();

                if (existingUserCheck == 0)
                {
                    _context.SaveChanges();
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("Email", "The combination of Email, Password, and Facility Name must be unique. ");
                }
            }

            return View(userPurchase);
        }