public async Task <Result> RemoveAsync(long groupUserId) { _logger.LogInformation($"Removing GroupUser. GroupUserId {groupUserId}"); Result <GroupUserEntity> getGroupUserResult = await _groupUserStore.SingleOrDefault(groupUserId); if (getGroupUserResult.Failure) { return(Result.Fail(getGroupUserResult)); } GroupUserEntity groupUser = getGroupUserResult.Value; Result canManageResult = await _groupUserStore.CanManageUser(groupUser); if (canManageResult.Failure) { return(Result.Fail(canManageResult)); } bool removeResult = await _groupUserDAO.Remove(groupUser); if (!removeResult) { _logger.LogError($"Failed to remove GroupUser. GroupUserId {groupUserId}"); return(Result.Fail(FAILED_TO_REMOVE_GROUP_USER)); } return(Result.Ok()); }
public async Task <CommonUtils.Result.Result> EditUser(long groupUserId, EditUserRequest editUserRequest) { IBaseSpecification <GroupUserEntity, GroupUserEntity> specification = SpecificationBuilder .Create <GroupUserEntity>() .Where(x => x.Id == groupUserId) .Include(x => x.User) .Build(); CommonUtils.Result.Result <GroupUserEntity> getGroupUserResult = await _groupUserStore.SingleOrDefault(specification); if (getGroupUserResult.Failure) { return(CommonUtils.Result.Result.Fail(getGroupUserResult)); } //TODO: change so that Edit takes AppUserEntity as parameter Core.Models.Result.Result updateResult = await EditUser(getGroupUserResult.Value.UserId, editUserRequest, ""); return(updateResult.ToNewResult()); }
public async Task <Result> Start(long groupUserId) { var specification = SpecificationBuilder .Create <GroupUserEntity>() .Where(x => x.Id == groupUserId) .Include(x => x.User) .Build(); Result <GroupUserEntity> getGroupUserResult = await _groupUserStore.SingleOrDefault(specification); if (getGroupUserResult.Failure) { return(Result.Fail(getGroupUserResult)); } return(await Start(getGroupUserResult.Value.User)); }
public Task <Result <GroupAdminUserDetailsModel> > Get(long groupUserId) { IBaseSpecification <GroupUserEntity, GroupAdminUserDetailsModel> specification = SpecificationBuilder .Create <GroupUserEntity>() .Where(x => x.Id == groupUserId) .Select(x => new GroupAdminUserDetailsModel( x.User.Id, x.Id, x.User.UserName, x.User.Email, x.User.FirstName, x.User.LastName, x.User.PhoneNumber, x.User.EmailConfirmed, x.User.PhoneNumberConfirmed, x.User.TwoFactorEnabled, x.User.Enabled, x.User.LockoutEnd.HasValue ? x.User.LockoutEnd.Value.ToString("o") : null)) .Build(); return(_groupUserStore.SingleOrDefault(specification)); }