[Authorize(Roles = "Admin")]//added by Goss
        public ActionResult DeleteUserAcctInfo(vm_userAcctInfo userAcctInfoDelete)
        {
            db.Database.ExecuteSqlCommand("DELETE FROM AspNetUsers WHERE Id=({0})", userAcctInfoDelete.aspNetId);

            return(Json(Url.Action("GetUserAcctInfo", "Account")));
            //return Json("complete");
        }
        [Authorize(Roles = "Admin")]//added by Goss
        public ActionResult UpdateUserAcctInfo(vm_userAcctInfo userAcctInfoUpdate)
        {
            if (ModelState.IsValid)
            {
                //load the roles held by this user into a list for later comparison
                List <string> roles          = UserManager.GetRoles(userAcctInfoUpdate.aspNetId).ToList();
                bool          currentlyAdmin = roles.Contains("Admin"); //determine if this user is currently an admin
                                                                        //System.Diagnostics.Debug.WriteLine(currentlyAdmin);

                if ((currentlyAdmin) && (!userAcctInfoUpdate.admin))    //if currently an admin, but selected to longer be an admin...
                {
                    UserManager.RemoveFromRole(userAcctInfoUpdate.aspNetId, "Admin");
                }

                if ((!currentlyAdmin) && (userAcctInfoUpdate.admin))//if not currently an admin, but selected to be an admin...
                {
                    UserManager.AddToRole(userAcctInfoUpdate.aspNetId, "Admin");
                }

                db.Database.ExecuteSqlCommand(
                    "UPDATE AspNetUsers " +
                    "SET " +

                    "Email = {1}, UserName = {2}, name = {3}, shortName = {4}, admin = {5}, active = {6} " +

                    "WHERE Id = {0}",
                    userAcctInfoUpdate.aspNetId, userAcctInfoUpdate.Email, userAcctInfoUpdate.UserName, userAcctInfoUpdate.name, userAcctInfoUpdate.ShortName,
                    userAcctInfoUpdate.admin, userAcctInfoUpdate.active);

                return(Json(Url.Action("GetUserAcctInfo", "Account")));
                //return Json("complete");
            }

            var modelErrors = new List <string>();

            foreach (var modelState in ModelState.Values)
            {
                foreach (var modelError in modelState.Errors)
                {
                    modelErrors.Add(modelError.ErrorMessage);
                }
            }

            userAcctInfoUpdate.ModelErrors = modelErrors;

            // If we got this far, something failed, redisplay form
            return(View(userAcctInfoUpdate));
            //return View("got it");
        }
        [Authorize(Roles = "Admin")]//added by Goss
        public ActionResult GetUserAcctInfo()
        {
            RegisterViewModel      regViewModel  = new RegisterViewModel();
            List <vm_userAcctInfo> userAcctInfos = new List <vm_userAcctInfo>();
            string        mainconn = ConfigurationManager.ConnectionStrings["allpaxServiceRecordEntities"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);

            sqlconn.Open();

            string sqlquery1 =
                "SELECT AspNetUsers.name, AspNetUsers.shortName, AspNetUsers.UserName, AspNetUsers.email, AspNetUsers.admin, AspNetUsers.active, AspNetUsers.Id " +

                "FROM [allpax_service_record].[dbo].[AspNetUsers]";

            SqlCommand     sqlcomm1 = new SqlCommand(sqlquery1, sqlconn);
            SqlDataAdapter sda1     = new SqlDataAdapter(sqlcomm1);
            DataTable      dt1      = new DataTable();

            sda1.Fill(dt1);
            foreach (DataRow dr1 in dt1.Rows)
            {
                vm_userAcctInfo userAcctInfo = new vm_userAcctInfo();

                userAcctInfo.name      = dr1[0].ToString();
                userAcctInfo.ShortName = dr1[1].ToString();
                userAcctInfo.UserName  = dr1[2].ToString();
                userAcctInfo.Email     = dr1[3].ToString();
                userAcctInfo.admin     = (bool)dr1[4];
                userAcctInfo.active    = (bool)dr1[5];
                userAcctInfo.aspNetId  = dr1[6].ToString();

                userAcctInfos.Add(userAcctInfo);//add all of the revelevant data objects to dailyReportByID...
            }

            regViewModel.userAcctInfo = userAcctInfos;

            sqlconn.Close();

            return(View(regViewModel));//...to be passed to the view
        }