public Component GetComponentByPriceAndQuality(ComponentType componentType, Quality quality, decimal priceTarget) { var partitionKeyFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, ComponentTypeHelpers.LookUpComponentTypeString(componentType)); var query = new TableQuery <ComponentEntity>().Where(partitionKeyFilter); var components = componentTable.ExecuteQuery(query) .Select(x => x.ToComponent()) .OrderByDescending(c => c.Quality) .ThenByDescending(c => c.Price); return(SelectFirstMatchingComponent(quality, priceTarget, components)); }
public static Component ToComponent(this ComponentEntity entity) { var component = JsonConvert.DeserializeObject <Component>(entity.Component); return(new Component { ID = int.Parse(entity.RowKey), Category = ComponentTypeHelpers.LookUpComponentTypeValue(entity.PartitionKey), Name = component.Name, Description = component.Description, Price = component.Price, Quality = component.Quality, //QualityHelpers.LookUpQualityValues(), VendorUrl = component.VendorUrl }); }
public ComponentEntity(int id, ComponentType cat) { PartitionKey = ComponentTypeHelpers.LookUpComponentTypeString(cat); RowKey = id.ToString(); }
public static IEnumerable <ComponentEntity> GetFakeComponentEntities(string partitionKey) { return(GetFakeComponents() .Where(c => c.Category == ComponentTypeHelpers.LookUpComponentTypeValue(partitionKey)) .Select(c => new ComponentEntity(c))); }