Ejemplo n.º 1
0
                public static LiveAdminPenalty FromPenalty(Penalty penalty)
                {
                    var p = new LiveAdminPenalty();

                    p.Id = penalty.Id;

                    var admin = penalty.Users.FirstOrDefault();

                    if (admin != null)
                    {
                        p.AdminId        = admin.CustId;
                        p.AdminName      = admin.Name;
                        p.AdminShortName = admin.ShortName;
                    }

                    p.InvestigatedDrivers = new List <LiveAdminDriver>();
                    if (penalty.IsUnderInvestigation)
                    {
                        foreach (var id in penalty.DriverIds)
                        {
                            var driver = Simulator.Instance.Drivers.FromId(id);
                            if (driver != null)
                            {
                                p.InvestigatedDrivers.Add(LiveAdminDriver.FromDriver(driver.Driver));
                            }

                            p.InvestigatedDriversDisplay = string.Join("<br />",
                                                                       p.InvestigatedDrivers.Select(d => d.Display));
                        }
                    }
                    else
                    {
                        var driver = Simulator.Instance.Drivers.FromId(penalty.Result.DriverId);
                        if (driver != null)
                        {
                            p.OffendingDriver = LiveAdminDriver.FromDriver(driver.Driver);
                        }
                        p.InvestigatedDriversDisplay = p.OffendingDriver.Display;
                    }

                    DateTime time = penalty.StartInvestigationTime.HasValue
                        ? penalty.StartInvestigationTime.Value
                        : _epoch;

                    p.TimeGMT = (time - _epoch).TotalMilliseconds;
                    p.Lap     = penalty.Lap;
                    p.Turn    = penalty.Turn;

                    //p.RuleId = ...
                    p.Decided          = !penalty.IsUnderInvestigation;
                    p.Reason           = penalty.Reason;
                    p.Result           = penalty.Result.DisplayLong;
                    p.ResultShort      = penalty.Result.DisplayShort;
                    p.ResultDecidedLap = penalty.DecidedLap;
                    p.Served           = penalty.Result.Served;

                    return(p);
                }
Ejemplo n.º 2
0
                public static LiveAdminPenalty FromPenalty(Penalty penalty)
                {
                    var p = new LiveAdminPenalty();
                    p.Id = penalty.Id;

                    var admin = penalty.Users.FirstOrDefault();
                    if (admin != null)
                    {
                        p.AdminId = admin.CustId;
                        p.AdminName = admin.Name;
                        p.AdminShortName = admin.ShortName;
                    }

                    p.InvestigatedDrivers = new List<LiveAdminDriver>();
                    if (penalty.IsUnderInvestigation)
                    {
                        foreach (var id in penalty.DriverIds)
                        {
                            var driver = Simulator.Instance.Drivers.FromId(id);
                            if (driver != null)
                            {
                                p.InvestigatedDrivers.Add(LiveAdminDriver.FromDriver(driver.Driver));
                            }

                            p.InvestigatedDriversDisplay = string.Join("<br />",
                                p.InvestigatedDrivers.Select(d => d.Display));
                        }
                    }
                    else
                    {
                        var driver = Simulator.Instance.Drivers.FromId(penalty.Result.DriverId);
                        if (driver != null)
                        {
                            p.OffendingDriver = LiveAdminDriver.FromDriver(driver.Driver);
                        }
                        p.InvestigatedDriversDisplay = p.OffendingDriver.Display;
                    }

                    DateTime time = penalty.StartInvestigationTime.HasValue
                        ? penalty.StartInvestigationTime.Value
                        : _epoch;
                    p.TimeGMT = (time - _epoch).TotalMilliseconds;
                    p.Lap = penalty.Lap;
                    p.Turn = penalty.Turn;

                    //p.RuleId = ...
                    p.Decided = !penalty.IsUnderInvestigation;
                    p.Reason = penalty.Reason;
                    p.Result = penalty.Result.DisplayLong;
                    p.ResultShort = penalty.Result.DisplayShort;
                    p.ResultDecidedLap = penalty.DecidedLap;
                    p.Served = penalty.Result.Served;

                    return p;
                }