public Result <Leaderboard> GetLeaderboard(string rallyId)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally => Result.Ok(_leaderboardFactory.Create(
                                              rally.Vehicles.Values.ToDto()))));
 }
Exemplo n.º 2
0
 public Result <VehicleStatistics> GetVehicleStatistics(string rallyId, string vehicleId)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally =>
                       Result.Create(rally.Vehicles.TryGetValue(vehicleId, out var v), v, ErrorMessages.VehicleDoesNotExist)
                       .Map(GetStatistics)));
 }
Exemplo n.º 3
0
 public Result RemoveVehicleFromRally(string rallyId, string vehicleId)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally => rally.RemoveVehicle(vehicleId)));
 }
 private Result AddVehicle(string rallyId, string vehicleId, string teamName, string model, DateTime manufacturingDate, Func <string, string, string, DateTime, IAmVehicle> createVehicle)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally => rally.AddVehicle(createVehicle(vehicleId, teamName, model, manufacturingDate))));
 }
 public Result StartRally(string rallyId)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally => rally.Start()));
 }
 public Result <RallyStatusInfo> GetRallyStatusInfo(string rallyId)
 {
     return(_rellyRepo.Find(rallyId)
            .OnFailureCompensate(failure => Result.Fail <IAmRally>(ErrorMessages.RallyNotFound))
            .OnSuccess(rally => Result.Ok(_rallyStatusInfoFactory.Create(rally))));
 }