private static List <VehicleCountByType> GetNumberOfVehiclesByType(IAmRally rally) { return(rally.Vehicles.Values .GroupBy(vehicle => vehicle.Type) .Select(group => new VehicleCountByType(group.Key.ToDto(), group.Count())) .ToList()); }
public static IAmRallyRepository SetUpRepoWithRally(string rallyId, IAmRally rally) { var rallyRepoMock = new Mock <IAmRallyRepository>(); rallyRepoMock .Setup(repo => repo.Find(rallyId)) .Returns(Result.Ok <IAmRally>(rally)); return(rallyRepoMock.Object); }
public RallyStatusInfo Create(IAmRally rally) { return(new RallyStatusInfo { Status = GetStatus(rally), NumberOfVehiclesByStatus = GetNumberOfVehiclesByStatus(rally), NumberOfVehiclesByType = GetNumberOfVehiclesByType(rally) }); }
private RallyStatus GetStatus(IAmRally rally) { return(rally.GetStatus().ToDto()); }
public Result Add(IAmRally rally) { return(Result.Create(!_rallies.ContainsKey(rally.Id), "Already exists.") .OnSuccess(() => _rallies.Add(rally.Id, rally))); }