private void AddToHistory(RoomHistory history) { var runningTotal = furnituresRunningTotal.ContainsKey(history.RoomId) ? furnituresRunningTotal[history.RoomId] : null; if (runningTotal != null) { foreach (var furniture in history.Furnitures) { var furnitureRunningTotal = runningTotal.FirstOrDefault(x => x.Furniture == furniture.Furniture); if (furnitureRunningTotal != null) { furnitureRunningTotal.Count += furniture.Count; } else { runningTotal.Add(furniture); } } history.Furnitures = runningTotal.ToList(); } else { furnituresRunningTotal[history.RoomId] = history.Furnitures; } history.Furnitures = history.Furnitures.Select(x => new FurnitureCount { Furniture = x.Furniture, RoomId = x.RoomId, Count = x.Count }).ToList(); roomHistories.Add(history); }
private static RoomHistoryClientData Map(RoomHistory data, bool isShort) { var result = new RoomHistoryClientData { Date = Map(data.Date) }; if (!isShort) { result.Name = data.Name; result.Description = Map(data.Furnitures); result.ActionType = data.ActionType; } return result; }