public async Task <PagedSearchResult <Archetype> > SearchArchetypes(ArchetypeSearch archetypeSearch, Language language) { var filter = ""; if (!string.IsNullOrEmpty(archetypeSearch.Class)) { filter = $"ClassName eq '{archetypeSearch.Class}'"; } if (!string.IsNullOrEmpty(archetypeSearch.Name)) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Name eq '{archetypeSearch.Name}'"; } if (archetypeSearch.ContentType.HasValue && archetypeSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{archetypeSearch.ContentType}'"; } var query = new TableQuery <Archetype>().Where(filter); var archetypes = await _tableStorage.QueryAsync($"archetypes{language}", query); switch (archetypeSearch.ArchetypeSearchOrdering) { case ArchetypeSearchOrdering.NameAscending: archetypes = archetypes.OrderBy(p => p.Name); break; case ArchetypeSearchOrdering.NameDescending: archetypes = archetypes.OrderByDescending(p => p.Name); break; case ArchetypeSearchOrdering.ContentTypeAscending: archetypes = archetypes.OrderBy(p => p.ContentType); break; case ArchetypeSearchOrdering.ContentTypeDescending: archetypes = archetypes.OrderByDescending(p => p.ContentType); break; case ArchetypeSearchOrdering.ClassAscending: archetypes = archetypes.OrderBy(p => p.ClassName); break; case ArchetypeSearchOrdering.ClassDescending: archetypes = archetypes.OrderByDescending(p => p.ClassName); break; } return(new PagedSearchResult <Archetype>(archetypes.ToList(), archetypeSearch.PageSize, archetypeSearch.CurrentPage)); }
public async Task <PagedSearchResult <Background> > SearchBackgrounds(BackgroundSearch backgroundSearch) { var filter = ""; if (!string.IsNullOrEmpty(backgroundSearch.Name)) { filter = $"Name eq '{backgroundSearch.Name}'"; } if (backgroundSearch.ContentType.HasValue && backgroundSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{backgroundSearch.ContentType.ToString()}'"; } var query = new TableQuery <Background>().Where(filter); var backgrounds = await _tableStorage.QueryAsync("backgrounds", query); switch (backgroundSearch.BackgroundSearchOrdering) { case BackgroundSearchOrdering.NameAscending: backgrounds = backgrounds.OrderBy(p => p.Name); break; case BackgroundSearchOrdering.NameDescending: backgrounds = backgrounds.OrderByDescending(p => p.Name); break; case BackgroundSearchOrdering.ContentTypeAscending: backgrounds = backgrounds.OrderBy(p => p.ContentType); break; case BackgroundSearchOrdering.ContentTypeDescending: backgrounds = backgrounds.OrderByDescending(p => p.ContentType); break; } return(new PagedSearchResult <Background>(backgrounds.ToList(), backgroundSearch.PageSize, backgroundSearch.CurrentPage)); }
public async Task <PagedSearchResult <Class> > SearchClasses(ClassSearch classSearch) { var filter = ""; if (!string.IsNullOrEmpty(classSearch.Name)) { filter = $"Name eq '{classSearch.Name}'"; } if (classSearch.ContentType.HasValue && classSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{classSearch.ContentType.ToString()}'"; } var query = new TableQuery <Class>().Where(filter); var classes = await _tableStorage.QueryAsync("classes", query); switch (classSearch.ClassSearchOrdering) { case ClassSearchOrdering.NameAscending: classes = classes.OrderBy(p => p.Name); break; case ClassSearchOrdering.NameDescending: classes = classes.OrderByDescending(p => p.Name); break; case ClassSearchOrdering.ContentTypeAscending: classes = classes.OrderBy(p => p.ContentType); break; case ClassSearchOrdering.ContentTypeDescending: classes = classes.OrderByDescending(p => p.ContentType); break; } return(new PagedSearchResult <Class>(classes.ToList(), classSearch.PageSize, classSearch.CurrentPage)); }
public async Task <List <User> > SearchUsersAsync(string username = "", string id = "") { var filter = ""; if (!string.IsNullOrEmpty(username)) { filter = $"Username eq '{username}'"; } if (!string.IsNullOrEmpty(id)) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Id eq '{id}'"; } var query = new TableQuery <User>().Where(filter); var users = await _tableStorage.QueryAsync("users", query); return(users.ToList()); }
public async Task <PagedSearchResult <Power> > SearchPowers(PowerSearch powerSearch) { var filter = ""; if (!string.IsNullOrEmpty(powerSearch.Name)) { filter = $"Name eq '{powerSearch.Name}'"; } if (powerSearch.ContentType.HasValue && powerSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{powerSearch.ContentType.ToString()}'"; } if (powerSearch.MaxLevel.HasValue) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Level le {powerSearch.MaxLevel.Value}"; } if (powerSearch.MinLevel.HasValue) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Level ge {powerSearch.MinLevel.Value}"; } if (powerSearch.PowerType.HasValue && powerSearch.PowerType != PowerType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} PowerType eq '{powerSearch.PowerType.ToString()}'"; } if (powerSearch.ForceAlignment.HasValue && powerSearch.ForceAlignment != ForceAlignment.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ForceAlignment eq '{powerSearch.ForceAlignment.ToString()}'"; } if (powerSearch.IsConcentration.HasValue) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Concentration eq {powerSearch.IsConcentration.ToString().ToLower()}"; } var query = new TableQuery <Power>().Where(filter); var powers = await _tableStorage.QueryAsync("powers", query); switch (powerSearch.PowerSearchOrdering) { case PowerSearchOrdering.NameAscending: powers = powers.OrderBy(p => p.Name); break; case PowerSearchOrdering.NameDescending: powers = powers.OrderByDescending(p => p.Name); break; case PowerSearchOrdering.ContentTypeAscending: powers = powers.OrderBy(p => p.ContentType); break; case PowerSearchOrdering.ContentTypeDescending: powers = powers.OrderByDescending(p => p.ContentType); break; case PowerSearchOrdering.LevelAscending: powers = powers.OrderBy(p => p.Level); break; case PowerSearchOrdering.LevelDescending: powers = powers.OrderByDescending(p => p.Level); break; case PowerSearchOrdering.PowerTypeAscending: powers = powers.OrderBy(p => p.PowerType); break; case PowerSearchOrdering.PowerTypeDescending: powers = powers.OrderByDescending(p => p.PowerType); break; case PowerSearchOrdering.ForceAlignmentAscending: powers = powers.OrderBy(p => p.ForceAlignment); break; case PowerSearchOrdering.ForceAlignmentDescending: powers = powers.OrderByDescending(p => p.ForceAlignment); break; case PowerSearchOrdering.IsConcentrationAscending: powers = powers.OrderBy(p => p.Concentration); break; case PowerSearchOrdering.IsConcentrationDescending: powers = powers.OrderByDescending(p => p.Concentration); break; } return(new PagedSearchResult <Power>(powers.ToList(), powerSearch.PageSize, powerSearch.CurrentPage)); }
public async Task <PagedSearchResult <EnhancedItem> > SearchEnhancedItems(EnhancedItemSearch enhancedItemSearch) { var filter = ""; if (!string.IsNullOrEmpty(enhancedItemSearch.Name)) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Name eq '{enhancedItemSearch.Name}'"; } if (enhancedItemSearch.ContentType.HasValue && enhancedItemSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{enhancedItemSearch.ContentType.ToString()}'"; } if (enhancedItemSearch.RequiresAttunement.HasValue) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} RequiresAttunement eq {enhancedItemSearch.RequiresAttunement.ToString().ToLower()}"; } if (enhancedItemSearch.Rarity.HasValue && enhancedItemSearch.Rarity != EnhancedItemRarity.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} SearchableRarity eq '{enhancedItemSearch.Rarity.ToString()}'"; } if (enhancedItemSearch.Type.HasValue && enhancedItemSearch.Type != EnhancedItemType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} Type eq '{enhancedItemSearch.Type.ToString()}'"; } if (enhancedItemSearch.AdventuringGearType.HasValue && enhancedItemSearch.AdventuringGearType != AdventuringGearType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} AdventuringGearType eq '{enhancedItemSearch.AdventuringGearType.ToString()}'"; } if (enhancedItemSearch.ConsumableType.HasValue && enhancedItemSearch.ConsumableType != ConsumableType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ConsumableType eq '{enhancedItemSearch.ConsumableType.ToString()}'"; } if (enhancedItemSearch.CyberneticAugmentationType.HasValue && enhancedItemSearch.CyberneticAugmentationType != CyberneticAugmentationType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} CyberneticAugmentationType eq '{enhancedItemSearch.CyberneticAugmentationType.ToString()}'"; } if (enhancedItemSearch.DroidCustomizationType.HasValue && enhancedItemSearch.DroidCustomizationType != DroidCustomizationType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} DroidCustomizationType eq '{enhancedItemSearch.DroidCustomizationType.ToString()}'"; } if (enhancedItemSearch.EnhancedWeaponType.HasValue && enhancedItemSearch.EnhancedWeaponType != EnhancedWeaponType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} EnhancedWeaponType eq '{enhancedItemSearch.EnhancedWeaponType.ToString()}'"; } if (enhancedItemSearch.EnhancedArmorType.HasValue && enhancedItemSearch.EnhancedArmorType != EnhancedArmorType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} EnhancedArmorType eq '{enhancedItemSearch.EnhancedArmorType.ToString()}'"; } if (enhancedItemSearch.EnhancedShieldType.HasValue && enhancedItemSearch.EnhancedShieldType != EnhancedShieldType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} EnhancedShieldType eq '{enhancedItemSearch.EnhancedShieldType.ToString()}'"; } if (enhancedItemSearch.FocusType.HasValue && enhancedItemSearch.FocusType != FocusType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} FocusType eq '{enhancedItemSearch.FocusType.ToString()}'"; } if (enhancedItemSearch.ItemModificationType.HasValue && enhancedItemSearch.ItemModificationType != ItemModificationType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ItemModificationType eq '{enhancedItemSearch.ItemModificationType.ToString()}'"; } if (enhancedItemSearch.ValuableType.HasValue && enhancedItemSearch.ValuableType != ValuableType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ValuableType eq '{enhancedItemSearch.ValuableType.ToString()}'"; } if (enhancedItemSearch.HasPrerequisite.HasValue) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} HasPrerequisite eq {enhancedItemSearch.HasPrerequisite.ToString().ToLower()}"; } var query = new TableQuery <EnhancedItem>().Where(filter); var enhancedItems = await _tableStorage.QueryAsync("enhancedItems", query); switch (enhancedItemSearch.EnhancedItemSearchOrdering) { case EnhancedItemSearchOrdering.None: break; case EnhancedItemSearchOrdering.NameAscending: enhancedItems = enhancedItems.OrderBy(p => p.Name); break; case EnhancedItemSearchOrdering.NameDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.Name); break; case EnhancedItemSearchOrdering.ContentTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.ContentType); break; case EnhancedItemSearchOrdering.ContentTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.ContentType); break; case EnhancedItemSearchOrdering.RequiresAttunementAscending: enhancedItems = enhancedItems.OrderBy(e => e.RequiresAttunement); break; case EnhancedItemSearchOrdering.RequiresAttunementDescending: enhancedItems = enhancedItems.OrderByDescending(e => e.RequiresAttunement); break; case EnhancedItemSearchOrdering.RarityOptionsAscending: enhancedItems = enhancedItems.OrderBy(p => p.RarityOptions.FirstOrDefault()); break; case EnhancedItemSearchOrdering.RarityOptionsDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.RarityOptions.LastOrDefault()); break; case EnhancedItemSearchOrdering.TypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.Type); break; case EnhancedItemSearchOrdering.TypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.Type); break; case EnhancedItemSearchOrdering.AdventuringGearTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.AdventuringGearType); break; case EnhancedItemSearchOrdering.AdventuringGearTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.AdventuringGearType); break; case EnhancedItemSearchOrdering.ConsumableTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.ConsumableType); break; case EnhancedItemSearchOrdering.ConsumableTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.ConsumableType); break; case EnhancedItemSearchOrdering.CyberneticAugmentationTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.CyberneticAugmentationType); break; case EnhancedItemSearchOrdering.CyberneticAugmentationTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.CyberneticAugmentationType); break; case EnhancedItemSearchOrdering.DroidCustomizationTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.DroidCustomizationType); break; case EnhancedItemSearchOrdering.DroidCustomizationTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.DroidCustomizationType); break; case EnhancedItemSearchOrdering.EnhancedArmorTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.EnhancedArmorType); break; case EnhancedItemSearchOrdering.EnhancedArmorTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.EnhancedArmorType); break; case EnhancedItemSearchOrdering.EnhancedShieldTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.EnhancedShieldType); break; case EnhancedItemSearchOrdering.EnhancedShieldTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.EnhancedShieldType); break; case EnhancedItemSearchOrdering.ItemModificationTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.ItemModificationType); break; case EnhancedItemSearchOrdering.ItemModificationTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.ItemModificationType); break; case EnhancedItemSearchOrdering.ValuableTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.ValuableType); break; case EnhancedItemSearchOrdering.ValuableTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.ValuableType); break; case EnhancedItemSearchOrdering.EnhancedWeaponTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.EnhancedWeaponType); break; case EnhancedItemSearchOrdering.EnhancedWeaponTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.EnhancedWeaponType); break; case EnhancedItemSearchOrdering.FocusTypeAscending: enhancedItems = enhancedItems.OrderBy(p => p.FocusType); break; case EnhancedItemSearchOrdering.FocusTypeDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.FocusType); break; case EnhancedItemSearchOrdering.HasPrerequisiteAscending: enhancedItems = enhancedItems.OrderBy(p => p.HasPrerequisite); break; case EnhancedItemSearchOrdering.HasPrerequisiteDescending: enhancedItems = enhancedItems.OrderByDescending(p => p.HasPrerequisite); break; default: throw new ArgumentOutOfRangeException(); } return(new PagedSearchResult <EnhancedItem>(enhancedItems.ToList(), enhancedItemSearch.PageSize, enhancedItemSearch.CurrentPage)); }
public async Task <PagedSearchResult <Equipment> > SearchEquipment(EquipmentSearch equipmentSearch) { var filter = ""; if (!string.IsNullOrEmpty(equipmentSearch.Name)) { filter = $"Name eq '{equipmentSearch.Name}'"; } if (equipmentSearch.ContentType.HasValue && equipmentSearch.ContentType != ContentType.None) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ContentType eq '{equipmentSearch.ContentType.ToString()}'"; } if (equipmentSearch.EquipmentCategory.HasValue && equipmentSearch.EquipmentCategory != EquipmentCategory.Unknown) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} EquipmentCategory eq '{equipmentSearch.EquipmentCategory.ToString()}'"; } if (equipmentSearch.ArmorClassification.HasValue && equipmentSearch.ArmorClassification != ArmorClassification.Unknown) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} ArmorClassification eq '{equipmentSearch.ArmorClassification.ToString()}'"; } if (equipmentSearch.WeaponClassification.HasValue && equipmentSearch.WeaponClassification != WeaponClassification.Unknown) { if (!string.IsNullOrEmpty(filter)) { filter = $"{filter} and"; } filter = $"{filter} WeaponClassification eq '{equipmentSearch.WeaponClassification.ToString()}'"; } var query = new TableQuery <Equipment>().Where(filter); var equipment = await _tableStorage.QueryAsync("equipment", query); switch (equipmentSearch.EquipmentSearchOrdering) { case EquipmentSearchOrdering.NameAscending: equipment = equipment.OrderBy(p => p.Name); break; case EquipmentSearchOrdering.NameDescending: equipment = equipment.OrderByDescending(p => p.Name); break; case EquipmentSearchOrdering.ContentTypeAscending: equipment = equipment.OrderBy(p => p.ContentType); break; case EquipmentSearchOrdering.ContentTypeDescending: equipment = equipment.OrderByDescending(p => p.ContentType); break; case EquipmentSearchOrdering.EquipmentCategoryAscending: equipment = equipment.OrderBy(p => p.EquipmentCategory); break; case EquipmentSearchOrdering.EquipmentCategoryDescending: equipment = equipment.OrderByDescending(p => p.EquipmentCategory); break; case EquipmentSearchOrdering.ArmorClassificationAscending: equipment = equipment.OrderBy(p => p.ArmorClassification); break; case EquipmentSearchOrdering.ArmorClassificationDescending: equipment = equipment.OrderByDescending(p => p.ArmorClassification); break; case EquipmentSearchOrdering.WeaponClassificationAscending: equipment = equipment.OrderBy(p => p.WeaponClassification); break; case EquipmentSearchOrdering.WeaponClassificationDescending: equipment = equipment.OrderByDescending(p => p.WeaponClassification); break; } return(new PagedSearchResult <Equipment>(equipment.ToList(), equipmentSearch.PageSize, equipmentSearch.CurrentPage)); }