public async Task <IList <string> > GetRolesAsync(UserInfo userInfo) { return(await userRoleRepository.Queryable() .Where(ur => ur.User.Id == userInfo.Id) .Select(i => i.Role.Key) .ToListAsync()); }
public async Task <UserInfo> FindByIdAsync(int userId) { var user = await userRepository .Queryable() .FirstOrDefaultAsync(u => u.Id == userId); if (user == null) { return(null); } var userInfo = new UserInfo { Id = user.Id, UserName = user.UserName, PasswordHash = user.PasswordHash, Email = user.Email }; return(userInfo); }
public IList <SelectionDataItemDetail> ListSelectionDataItems(string attributeName) { var referenceData = _selectionDataItemRepository.Queryable() .Where(di => di.AttributeKey == attributeName) .ToList(); IList <SelectionDataItemDetail> selectionDataItems = (from item in referenceData select new SelectionDataItemDetail { SelectionDataItemId = item.Id, AttributeKey = item.AttributeKey, SelectionKey = item.SelectionKey, DataItemValue = item.Value }).ToList(); return(selectionDataItems); }
public async Task AddToRoleAsync(UserInfo userInfo, string roleName) { var user = userRepository.Get(userInfo.Id); var role = roleRepository.Queryable().SingleOrDefault(r => r.Key == roleName); if (user == null) { throw new InvalidOperationException("User not found."); } if (role == null) { throw new InvalidOperationException("Role not recognised."); } await Task.Run(() => { userRoleRepository.Save(new UserRole { User = user, Role = role }); }); }
/// <summary> /// Retrieves the attribute configurations for the specified type. /// </summary> /// <param name="typeName">Name of the type.</param> /// <returns></returns> public IList <CustomAttributeConfiguration> RetrieveAttributeConfigurationsForType(string typeName) { return(_customAttributeConfigurationRepository.Queryable() .Where(ca => ca.ExtendableTypeName == typeName) .ToList()); }
public bool HasAssociatedData(DatasetElement element) { var hasData = false; hasData = (element.DatasetCategoryElements.Count > 0 || element.DatasetElementSubs.Count > 0 || _instanceValueRepository.Queryable().Any(div => div.DatasetElement.Id == element.Id)); return(hasData); }
/// <summary> /// Retrieves the selection data for specified attribute attributeKey. /// </summary> /// <param name="attributeKey">The attribute key.</param> /// <returns></returns> public ICollection <SelectionDataItem> RetrieveSelectionDataForAttribute(string attributeKey) { return(_selectionDataItemRepository.Queryable() .Where(di => di.AttributeKey == attributeKey) .ToList()); }