Exemplo n.º 1
0
        private void ProductsDataGrid_Sorting(object sender, DataGridSortingEventArgs e)
        {
            e.Handled = true;
            User_ViewModel mainViewModel = (User_ViewModel)DataContext;
            string         sortField     = String.Empty;

            switch (e.Column.SortMemberPath)
            {
            case ("pid"):
                sortField = "pid";
                break;

            case ("pdate"):
                sortField = "pdate";
                break;
            }

            ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ?
                                          ListSortDirection.Ascending : ListSortDirection.Descending;

            bool sortAscending = direction == ListSortDirection.Ascending;

            mainViewModel.Sort(sortField, sortAscending);

            currentSortColumn.SortDirection = null;

            e.Column.SortDirection = direction;

            currentSortColumn    = e.Column;
            currentSortDirection = direction;
        }
        public List <User_ViewModel> getAllUsers()
        {
            using (var db = new BaseEntities())
            {
                var users = db.AspNetUsers.AsQueryable();
                List <User_ViewModel> list_user_viewModel = new List <User_ViewModel>();
                foreach (var item in users)
                {
                    var    setting = db.Settings.FirstOrDefault(s => s.UserId == item.Id);
                    string appId   = string.Empty;
                    if (setting != null)
                    {
                        appId = setting.AppId;
                    }

                    User_ViewModel user_viewModel = new User_ViewModel {
                        Email    = item.Email,
                        Id       = item.Id,
                        UserName = item.UserName,
                        AppId    = appId
                    };
                    list_user_viewModel.Add(user_viewModel);
                }


                return(list_user_viewModel);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 注册用户
        /// <param name="User">用户注册资料</param>
        /// <param name="UserEX">用户附加详细资料</param>
        /// </summary>
        /// <returns></returns>
        public bool UserReg(User_ViewModel User, aspnet_UsersEX UserEX)
        {
            String guid = Guid.NewGuid().ToString();

            User = User ?? new User_ViewModel()
            {
                UserName     = guid,
                UserPassword = guid,
                Email        = "",
                Answer       = "no",
                Question     = "no"
            };
            MembershipCreateStatus state     = new MembershipCreateStatus();
            MembershipUser         Temp_User = Membership.CreateUser(User.UserName, User.UserPassword, User.Email, User.Question, User.Answer, false, out state);

            if (state == MembershipCreateStatus.Success)
            {
                UserEX.User_ID = (Guid)Temp_User.ProviderUserKey;
            }
            else
            {
                return(false);
            }

            if (!DB_UserEX.Insert(UserEX))
            {
                Membership.DeleteUser(Temp_User.UserName);
            }
            else
            {
                Roles.AddUserToRole(User.UserName, "普通会员");
            }
            return(true);
        }
Exemplo n.º 4
0
        public AllMemberships()
        {
            uow  = ObjectFactory.GetInstance <IUnitOfWork>();
            user = ObjectFactory.GetInstance <IUser>();

            userData = new User_ViewModel(new UserModel(), uow);
            registerMessenger();

            InitializeComponent();

            DataContext = this;
        }
Exemplo n.º 5
0
        public async Task <IActionResult> RemoveAsync([FromBody] User_ViewModel collection)
        {
            try {
                var model    = _mapper.Map <User_Entity>(collection);
                var response = await _userContainer.RemoveAsync(model);

                return(View(response));
            }
            catch (Exception ex) {
                Log.Error(ex, MethodBase.GetCurrentMethod().Name);
            }
            return(View());
        }
Exemplo n.º 6
0
 public NewMembership(UserModel user)
 {
     uow = ObjectFactory.GetInstance <IUnitOfWork>();
     registerMessenger();
     InitializeComponent();
     if (user != null)
     {
         userData = new User_ViewModel(user, uow);
     }
     else
     {
         userData = new User_ViewModel(new UserModel(), uow);
     }
     DataContext = this;
 }
Exemplo n.º 7
0
        public SearchUser(string destination)
        {
            uow  = ObjectFactory.GetInstance <IUnitOfWork>();
            user = ObjectFactory.GetInstance <IUser>();

            userData = new User_ViewModel(new UserModel(), uow);
            registerMessenger();

            InitializeComponent();
            if (!string.IsNullOrEmpty(destination) && destination.Equals("Word"))
            {
                des = "1";
            }
            if (!string.IsNullOrEmpty(destination) && destination.Equals("Kinnect"))
            {
                des = "2";
            }

            DataContext = this;
        }
Exemplo n.º 8
0
 public User_Management()
 {
     InitializeComponent();
     UserData    = new User_ViewModel(new DbModel.ViewModel.UserVM.UserModel());
     DataContext = this;
 }