public bool Buy(ngUserModel user, int day, string foodId, decimal val) { bool res = false; /* ExcelTable excelTable = ExcelManager.Inst.Doc.GetExcelTable(day); ExcelRow row = excelTable.GetRowByFoodId(foodId); ExcelCell cell = row.EnsureCell(user.Column); decimal prevVal = cell.Value; cell.Value = val; */ bool isNewFood = true; List<ngOrderEntry> orders = GetOrders(user, day); foreach (ngOrderEntry order in orders) { if (order.FoodId.Equals(foodId, StringComparison.OrdinalIgnoreCase)) { order.Count = val; isNewFood = false; } } if (isNewFood) { ngOrderEntry item = new ngOrderEntry(); item.Count = val; item.FoodId = foodId; orders.Add(item); } List<ngOrderEntry> newOrders = ApiUtils.AddContainersToFood(user, day, orders); if (BatchCellUpdater.Update(user, day, newOrders)) { res = true; } return res; }
public List<ngOrderEntry> GetOrders(ngUserModel user, int day) { List<ngOrderEntry> res = new List<ngOrderEntry>(); ExcelTable excelTable = ExcelManager.Inst.Doc.GetExcelTable(day); if (null != excelTable) { List<ExcelRow> rows = excelTable.Rows; foreach (ExcelRow row in rows) { ExcelCell cell = row.GetCell(user.Column); if (cell != null && row.HasPrice && cell.Value > 0) { ngOrderEntry item = new ngOrderEntry(); item.Count = cell.Value; item.FoodId = row.GetFoodId(); res.Add(item); } } } return res; }