コード例 #1
0
        public List <UserDisplayViewModel> GetUsers()
        {
            string      sqlGetUser = "******";
            List <User> users      = SqlDataAccess.LoadData <User>(sqlGetUser);

            List <UserDisplayViewModel> displayUsers = new List <UserDisplayViewModel>();
            var divRepo = new DivisionRepository();
            var disRepo = new DistrictRepository();

            foreach (var user in users)
            {
                var displayUser = new UserDisplayViewModel();
                displayUser.UserId         = user.UserId;
                displayUser.FirstName      = user.FirstName;
                displayUser.LastName       = user.LastName;
                displayUser.UserName       = user.UserName;
                displayUser.Email          = user.Email;
                displayUser.Mobile         = user.Mobile;
                displayUser.Gender         = user.Gender;
                displayUser.Division       = divRepo.GetDivision(user.DivisionId);
                displayUser.District       = disRepo.GetDistrictsById(user.DistrictId);
                displayUser.LastEducation  = user.LastEducation;
                displayUser.Occupation     = user.Occupation;
                displayUser.DoB            = user.DoB;
                displayUser.PresentAddress = user.PresentAddress;

                displayUsers.Add(displayUser);
            }

            return(displayUsers);
        }
コード例 #2
0
        public UserEditViewModel Registration()
        {
            var divRepo = new DivisionRepository();
            var disRepo = new DistrictRepository();

            var user = new UserEditViewModel();

            user.Divisions = divRepo.GetDivisions();
            user.Districts = disRepo.GetDistricts();

            return(user);
        }
コード例 #3
0
        public UserEditViewModel GetUser(int id)
        {
            UserEditViewModel user = new UserEditViewModel();
            string            sql  = "Select * from users where userid = " + id;
            var users = SqlDataAccess.LoadData <UserEditViewModel>(sql);

            if (users.Count > 0)
            {
                user = users[0];
            }

            var divRepo = new DivisionRepository();
            var disRepo = new DistrictRepository();

            user.Divisions = divRepo.GetDivisions();
            user.Districts = disRepo.GetDistricts(user.DivisionId);

            return(user);
        }