/// <summary> /// Gets preferences of the specified <typeparamref name="TPreference"/> type, /// including the associated user. /// </summary> /// <typeparam name="TPreference"></typeparam> /// <returns></returns> public virtual IQueryable <UserPreferencesModel> Execute <TPreference>() where TPreference : UserPreference { return(DbSets.Set <ApplicationUser>().Select(u => new UserPreferencesModel() { User = u, Person = u.Person, SubscriptionPreferences = u.Preferences.OfType <SubscriptionPreference>() })); }
public virtual IProjectableQuery <TItem> Execute <TItem>(string personId) where TItem : Case { var items = from item in DbSets.Set <TItem>() where item.CaseUsers.Any(c => c.Person.Id == personId) select item; return(items.AsProjectable(Mapper)); }
public virtual IProjectableQuery <TItem> Execute <TItem>(SituationModel situationModel) where TItem : Item { var items = from item in DbSets.Set <TItem>() where item.AppliesToContexts.Any(c => situationModel.Contexts.Contains(c.Id)) && item.AppliesToLosses.Any(c => situationModel.Losses.Contains(c.Id)) && item.AppliesToRelationships.Any(c => situationModel.Relationships.Contains(c.Id)) select item; return(items.AsProjectable(Mapper)); }
public virtual IQueryable <ApplicationUser> Execute(bool?isStaff) { var query = DbSets.Set <ApplicationUser>().AsQueryable(); if (isStaff == true) { query = query.Where(u => u.Claims.Any(c => c.ClaimType == Constants.Claims.Staff)); } else if (isStaff == false) { query = query.Where(u => u.Claims.All(c => c.ClaimType != Constants.Claims.Staff)); } return(query); }
public virtual IQueryable <SubscriptionPreferenceDetails> GetSubscriptionPreferenceDetails([NotNull] string subscriptionName) { if (subscriptionName == null) { throw new ArgumentNullException(nameof(subscriptionName)); } return(DbSets.Set <SubscriptionPreference>() .Where(sp => sp.SubscriptionName == subscriptionName) .Select(sp => new SubscriptionPreferenceDetails() { UserId = sp.User.Id, EmailAddress = sp.User.Person.EmailAddress, PhoneNumber = sp.User.Person.PhoneNumber, IsSmsRequested = sp.IsSmsRequested, IsEmailRequested = sp.IsEmailRequested, })); }
/// <summary> /// Gets a <typeparamref name="TModel"/> (which must have a query-compatible mapping from <typeparamref name="TEntity"/>) by <paramref nam="id"/>. /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual TModel Execute <TModel>(object id) => Mapper.Map <TModel>(DbSets.Set <TEntity>().Find(id));
/// <summary> /// Gets a <typeparamref name="TEntity"/> by <paramref nam="id"/>; /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual TEntity Execute(object id) => DbSets.Set <TEntity>().Find(id);