Esempio n. 1
0
        public UserViewModel(UserManagementDb userManagementDb, List <GroupDetail> groupDetails, UserGroupDetail userGroupDetail)
        {
            this.dbContext = userManagementDb;
            this.id        = userGroupDetail.UserID;
            this.name      = userGroupDetail.Name;
            this.username  = userGroupDetail.UserName;
            this.groupId   = userGroupDetail.GroupID;
            this.groups    = new List <GroupViewModel>(groupDetails.Select(gd => new GroupViewModel(userManagementDb, gd)));

            string errorMessage = string.Empty;
            var    userdataset  = userManagementDb.GetUserDetails(this.id, out errorMessage);
            var    userDetail   = GetUserDetail(userdataset);

            if (userDetail != null)
            {
                this.password = userDetail.Password;
                //this.SelectedGroup = this.Groups.SingleOrDefault(g => g.GroupID == userDetail.GroupID);
            }

            this.SelectedGroup = this.Groups.SingleOrDefault(g => g.GroupID == userGroupDetail.GroupID);

            this.SaveCommand   = new RelayCommand(this.ExecuteSaveCommand, this.CanExecuteSaveCommand);
            this.ResetComand   = new AnotherCommandImplementation(ExecuteResetCommand, CanExecuteResetCommand);
            this.DeleteCommand = new RelayCommand(this.ExecuteDeleteCommand, this.CanExecuteDeleteCommand);
        }
        public async Task <IHttpActionResult> GetUserDetails(string userId)
        {
            try
            {
                DataSet dataSet = await Task.Run(() => usermanagementDb.GetUserDetails(userId));

                if (dataSet == null)
                {
                    return(NotFound());
                }

                return(Ok(dataSet));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }