コード例 #1
0
        public List <StandartComboBox> GetAllRoles()
        {
            List <StandartComboBox> Result = new List <StandartComboBox>();
            string    Query = "GetComboRole";
            DataTable dt    = new DataTable();

            dbAccess.strConn = conn;
            dt = dbAccess.GetDataTable_not_async(Query);

            foreach (DataRow dr in dt.Rows)
            {
                Result.Add(
                    new StandartComboBox
                {
                    Value = Convert.ToString(dr["Value"]),
                    Text  = Convert.ToString(dr["Text"])
                });
            }
            return(Result);
        }
コード例 #2
0
        // Controllers

        // GET: /Admin/
        // [Authorize(Roles = "Administrator")]
        #region public ActionResult Index(string searchStringUserNameOrEmail)
        public ActionResult Index(string searchStringUserNameOrEmail, string currentFilter, int?page)
        {
            dbAccess dbAccess = new dbAccess();
            string   conn     = ConfigurationManager.ConnectionStrings["GetConn"].ConnectionString;

            try
            {
                List <ExpandedUserDTO> Result = new List <ExpandedUserDTO>();
                string    Query = "GetUserAll";
                DataTable dt    = new DataTable();
                dbAccess.strConn = conn;
                dt = dbAccess.GetDataTable_not_async(Query);

                foreach (DataRow dr in dt.Rows)
                {
                    Result.Add(
                        new ExpandedUserDTO
                    {
                        Photo          = Convert.ToString(dr["Photo"]),
                        NameIdentifier = Convert.ToString(dr["NameIdentifier"]),
                        UserName       = Convert.ToString(dr["UserName"]),
                        Email          = Convert.ToString(dr["Email"]),
                        PhoneNumber    = Convert.ToString(dr["PhoneNumber"]),
                        RoleName       = Convert.ToString(dr["Name"])
                    });
                }
                return(View(Result));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Error: " + ex);
                List <ExpandedUserDTO> Result = new List <ExpandedUserDTO>();

                return(View(Result));
            }
            //try
            //{
            //    searchStringUserNameOrEmail = "";
            //    ViewBag.CurrentFilter = searchStringUserNameOrEmail;

            //    List<ExpandedUserDTO> col_UserDTO = new List<ExpandedUserDTO>();
            //    var result = UserManager.Users
            //        .Where(x => x.UserName.Contains(searchStringUserNameOrEmail))
            //        .OrderBy(x => x.UserName)
            //        //.Skip(intSkip)
            //        //.Take(intPageSize)
            //        .ToList();

            //    foreach (var item in result)
            //    {
            //        ExpandedUserDTO objUserDTO = new ExpandedUserDTO();

            //        objUserDTO.UserName = item.UserName;
            //        objUserDTO.NameIdentifier = item.NameIdentifier;
            //        objUserDTO.Email = item.Email;
            //        objUserDTO.PhoneNumber = item.PhoneNumber;
            //        objUserDTO.LockoutEndDateUtc = item.LockoutEndDateUtc;

            //        col_UserDTO.Add(objUserDTO);
            //    }       );

            //    return View(col_UserDTO);
            //}
            //catch (Exception ex)
            //{
            //    ModelState.AddModelError(string.Empty, "Error: " + ex);
            //    List<ExpandedUserDTO> col_UserDTO = new List<ExpandedUserDTO>();

            //    return View(col_UserDTO.ToPagedList(1, 25));
            //}
        }