public void AddWineToDisplay(WineItem wineItem) { if (winesToDisplay == null) { winesToDisplay = new List <WineItem>(); } winesToDisplay.Add(wineItem); }
public void AddTrolleyItemToDisplay(WineItem wineItem, int amount) { if (trolleyItemsToDisplay == null) { trolleyItemsToDisplay = new Dictionary <WineItem, int>(); } trolleyItemsToDisplay.Add(wineItem, amount); }
public WineEntity(WineItem item) { this.PartitionKey = item.WineType; this.RowKey = item.WineId; this.WineName = item.WineName; this.WinePrice = item.WinePrice; this.WineInStock = item.WineInStock; this.WinePicture = item.WinePicture; this.WineInfo = item.WineInfo; }
public async Task UpdateEntityAsync(WineItem changedItem, string storageConnectionString) { CloudStorageAccount storage = CloudStorageAccount.Parse(storageConnectionString); CloudTableClient tableClient = storage.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("inventory"); await table.CreateIfNotExistsAsync(); var operation = TableOperation.Retrieve <WineEntity>(changedItem.WineType, changedItem.WineId); var result = await table.ExecuteAsync(operation); var retrievedEntity = (WineEntity)result.Result; retrievedEntity.WineInfo = changedItem.WineInfo; retrievedEntity.WineName = changedItem.WineName; retrievedEntity.WinePrice = changedItem.WinePrice; retrievedEntity.WineInStock = changedItem.WineInStock; retrievedEntity.WinePicture = changedItem.WinePicture; operation = TableOperation.Replace(retrievedEntity); await table.ExecuteAsync(operation); }
static void Main() { DataProcessor dataProcessor = new DataProcessor(); List <ClientItem> wineData = dataProcessor.ReadFile(); KMeans kMeans = new KMeans(wineData); kMeans.ExecuteKmeans(); Console.WriteLine(kMeans.SumSquaredError); // get results (clients) // get results per offer List <Cluster> bestCLusters = kMeans.BestClusters; // iterate over clusters foreach (var cluster in bestCLusters) { // iterate per client per cluster foreach (var client in cluster.ClientItems) { // iteratie per wineItem per client per cluster for (int i = 0; i < client.WineData.Count; i++) { // if wine item is bought if (client.WineData[i] == 1) { //check if WineItem exist in list<WineItem> if (!cluster.WineItems.Any(x => x.WineOfferId == i + 1)) { WineItem item = new WineItem(); item.WineOfferId = i + 1; item.ClientsOfferTaken.Add(client); cluster.WineItems.Add(item); } else { //append to existing wineItem try { var myCluster = cluster.WineItems.First(x => x.WineOfferId == i + 1); myCluster.ClientsOfferTaken.Add(client); } catch (Exception e) { Console.WriteLine(e); } //item.ClientsOfferTaken.Add(client); //wineItems.Add(item); } } } } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }