예제 #1
0
        public ServiceResponse RemoveFromGroup(UserGroupDetail userGrpDetail)
        {
            ServiceResponse res = new ServiceResponse();

            var userGrp = _userGrpRepository.GetSingleById((int)userGrpDetail.UserGroupId);

            if (userGrp == null)
            {
                res.OnError("Group does not exist");
                return(res);
            }

            var user = _userRepository.GetSingleById((int)userGrpDetail.UserId);

            if (user == null)
            {
                res.OnError("User does not exist");
                return(res);
            }

            var userGroupDetail = _userGrpDetailRepository.GetSingleByCondition(x => x.UserGroupId == userGrp.UserGroupId && x.UserId == user.UserId);

            if (userGroupDetail == null)
            {
                res.OnError("Group or User does not exist");
                return(res);
            }
            _userGrpDetailRepository.Delete(userGroupDetail.Id);
            res.OnSuccess(userGroupDetail);
            this.Save();
            return(res);
        }
예제 #2
0
        public ServiceResponse RemoveFromGroup(UserGroupDetail userGrpDetail)
        {
            ServiceResponse result = new ServiceResponse();

            try
            {
                result = _userService.RemoveFromGroup(userGrpDetail);
            }
            catch (Exception ex)
            {
                result.OnExeption(ex);
            }


            return(result);
        }
예제 #3
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);
        }