コード例 #1
0
        public async Task <IActionResult> GetById(int id)
        {
            Models.Crew crew = await _context.Crews.Include(x => x.Results).FirstOrDefaultAsync(x => x.BroeCrewId == id);

            if (crew == null)
            {
                return(NotFound());
            }

            Models.Competition comp = await _context.Competitions.Include(c => c.TimingPoints)
                                      .FirstOrDefaultAsync(c => c.CompetitionId == crew.CompetitionId);

            Crew output = ResultsHelper.BuildCrew(_mapper, comp, crew);

            if (comp.TimingPoints.Count > 0)
            {
                Models.TimingPoint lastPoint = comp.TimingPoints.Last();
                List <Models.Crew> crews     = ResultsHelper.OrderCrews(comp.Crews, comp, lastPoint);
                output.Rank = crew.Rank(crews, comp.TimingPoints.First(), lastPoint);
            }
            for (int i = 1; i < crew.Results.Count; i++)
            {
                List <Models.Crew> crews = ResultsHelper.OrderCrews(comp.Crews, comp, comp.TimingPoints[i]);
                output.Results[i].Rank = crew.Rank(crews, comp.TimingPoints.First(), comp.TimingPoints[i]);
            }
            return(Ok(output));
        }
コード例 #2
0
        public async Task <IActionResult> ListByCompetition(int id, string s, int?award = null)
        {
            List <Models.Crew> crews;

            Models.Competition comp = await _context.Competitions.Include(c => c.TimingPoints).FirstOrDefaultAsync(c => c.CompetitionId == id);

            if (comp is null)
            {
                return(NotFound());
            }

            if (award == null)
            {
                crews = await _context.Crews.Include(c => c.Results).Where(c => c.CompetitionId == id).ToListAsync();
            }
            else
            {
                Models.Award dbAward = await _context.Awards.Include("Crews.Crew.Results")
                                       .FirstOrDefaultAsync(a => a.AwardId == award);

                crews = dbAward.Crews.Select(x => x.Crew).ToList();
            }

            List <Crew> results = ResultsHelper.BuildCrewsList(_mapper, comp, crews);

            if (String.IsNullOrEmpty(s))
            {
                return(Ok(results));
            }
            else
            {
                return(Ok(results.Where(x => x.Name.ToUpper(CultureInfo.CurrentCulture)
                                        .Contains(s.ToUpper(CultureInfo.CurrentCulture), StringComparison.CurrentCulture)).ToList()));
            }
        }
コード例 #3
0
        public void BuildResultsList_WithFirstCrewTimeOnlyAndSecondCrewAtBarnes_ShouldReturnFirstCrewSecond()
        {
            List <Crew> crews = new List <Crew>();
            Crew        crew1 = new Crew {
                BroeCrewId = 1, Competition = Competition
            };

            crew1.BroeCrewId  = 1;
            crew1.Competition = Competition;
            crew1.Results.Add(new Result(StartPoint, crew1, new TimeSpan(2, 0, 0)));
            crew1.Results.Add(new Result(BarnesPoint, crew1, new TimeSpan(2, 4, 0)));
            crews.Add(crew1);

            Crew crew2 = new Crew {
                BroeCrewId = 2, Competition = Competition, IsTimeOnly = true
            };

            crew2.Results.Add(new Result(StartPoint, crew2, new TimeSpan(2, 1, 0)));
            crew2.Results.Add(new Result(FinishPoint, crew2, new TimeSpan(2, 20, 0)));
            crews.Add(crew2);

            List <HeadRaceTimingSite.Api.Resources.Crew> results = ResultsHelper.BuildCrewsList(mapper, Competition, crews);

            Assert.AreEqual(1, results[0].Id);
            Assert.AreEqual(2, results[1].Id);
        }
コード例 #4
0
        public ActionResult Index()
        {
            // Connect to the "Head" database and issue an elastic query
            var connectionString = Config.GetHeadDatabaseConnectionString();

            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandText    = @"

-- Query for all line items on all orders by a specific customer

select c.ContactName, o.OrderId, o.OrderDate, od.ProductID, p.ProductName, (od.Quantity * od.UnitPrice) as line_item_total
from [dbo].[Orders] o
left join [dbo].[Order Details] od on od.OrderId = o.OrderId
left join [dbo].[Products] p on p.ProductId = od.ProductId
left join [dbo].[Customers] c on c.CustomerId = o.CustomerId
where o.CustomerId = 25;

";

                    using (var reader = cmd.ExecuteReader())
                    {
                        var results = ResultsHelper.ReadResults(reader);

                        // Render the results!
                        return(View(new ResultsViewModel(results, cmd.CommandText, reader.RecordsAffected)));
                    }
                }
            }
        }
コード例 #5
0
        public ActionResult Index()
        {
            // Connect to the "Head" database and issue a query against the "Products" remote table
            var connectionString = Config.GetHeadDatabaseConnectionString();

            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandText    = @"

select 'external' as source, name from sys.external_tables;

select 'local' as source, name from sys.tables where schema_name(schema_id) = 'dbo';

select 'shard' as source, ServerName, DatabaseName from [__ShardManagement].[ShardsGlobal];

";

                    using (var reader = cmd.ExecuteReader())
                    {
                        var results = ResultsHelper.ReadResults(reader);

                        // Render the results!
                        return(View(new ResultsViewModel(results, cmd.CommandText, reader.RecordsAffected)));
                    }
                }
            }
        }
コード例 #6
0
        public async Task <IActionResult> DetailsAsCsv(int?id)
        {
            Competition competition = await _context.Competitions.Include(c => c.TimingPoints).FirstOrDefaultAsync(c => c.CompetitionId == id);

            IEnumerable <Crew> crews = await _context.Crews.Where(c => c.CompetitionId == id).Include(x => x.Results)
                                       .Include("Athletes.Athlete").Include(x => x.Penalties).ToListAsync();

            return(Ok(_mapper.Map <IList <CsvCrewViewModel> >(ResultsHelper.BuildCrewsList(_mapper, competition, crews))));
        }
コード例 #7
0
        private static void Main()
        {
            var pd = new PatientData();

            pd.GestationalAge.Value = 22.42857143;
            pd.FemurLength.Value    = 59;
            var list = ResultsHelper.GetEmptyResults(pd);

            foreach (var r in list)
            {
                if (r.ZScoreable)
                {
                    //System.Console.WriteLine(r.Name + ": " + r.Formula.GetZScore(3.2));
                    r.Formula.UseFL = true;
                    Debug.WriteLine(r.Formula.GetZScore(3.2));
                }
            }
        }
コード例 #8
0
        private IList <ResultsHelper> PrepareResults(IProject project, bool sort)
        {
            List <ResultsHelper> res = new List <ResultsHelper>();

            for (int w = 0; w < warriorsCount; w++)
            {
                IWarrior      warrior = project.Warriors[w];
                ResultsHelper r       = new ResultsHelper();
                r.originalIndex = w;
                r.score         = score[w];
                r.warrior       = warrior;
                res.Add(r);
            }
            if (sort)
            {
                res.Sort();
            }
            return(res);
        }
コード例 #9
0
        public void BuildResultsList_WithNoCrewsWithTimesButTimeOnlyFirst_ShouldReturnStartOrder()
        {
            List <Crew> crews = new List <Crew>();
            Crew        crew1 = new Crew {
                BroeCrewId = 1, IsTimeOnly = true, Competition = Competition
            };

            crews.Add(crew1);

            Crew crew2 = new Crew {
                BroeCrewId = 2, Competition = Competition
            };

            crews.Add(crew2);

            List <HeadRaceTimingSite.Api.Resources.Crew> results = ResultsHelper.BuildCrewsList(mapper, Competition, crews);

            Assert.AreEqual(1, results[0].Id);
            Assert.AreEqual(2, results[1].Id);
        }
コード例 #10
0
        private void ExtractResultsFromIntent()
        {
            // Load and unparcel scores
            IParcelable[] parcelableScores = this.Intent.GetParcelableArrayExtra(ExtraScores);
            ScoreOutput[] scores           = new ScoreOutput[parcelableScores.Length];
            for (int i = 0; i < parcelableScores.Length; i++)
            {
                scores[i] = ((ParcelableScoreOutput)parcelableScores[i]).Value;
            }

            // Load and unparcel CAMs
            IParcelable[] parcelableCAMs = this.Intent.GetParcelableArrayExtra(ExtraCAMs);
            CAM[]         cams           = new CAM[parcelableCAMs.Length];
            for (int i = 0; i < parcelableCAMs.Length; i++)
            {
                cams[i] = ((ParcelableCAM)parcelableCAMs[i]).Value;
            }

            // Collapse into results array
            results = ResultsHelper.BuildConditionResultArray((ChestCondition[])Enum.GetValues(typeof(ChestCondition)), scores, cams, conditionColors);
        }
コード例 #11
0
        public void BuildResultsList_WithSingleCrewWithTime_ShouldRankItFirst()
        {
            List <Crew> crews = new List <Crew>();
            Crew        crew1 = new Crew {
                BroeCrewId = 1, Competition = Competition
            };

            crews.Add(crew1);

            Crew crew2 = new Crew {
                BroeCrewId = 2, Competition = Competition
            };

            crew2.Results.Add(new Result(StartPoint, crew2, new TimeSpan(2, 0, 0)));
            crew2.Results.Add(new Result(FinishPoint, crew2, new TimeSpan(2, 20, 0)));
            crews.Add(crew2);

            List <HeadRaceTimingSite.Api.Resources.Crew> results = ResultsHelper.BuildCrewsList(mapper, Competition, crews);

            Assert.AreEqual(2, results[0].Id);
            Assert.AreEqual(1, results[1].Id);
        }
コード例 #12
0
 public override string ResultToString(object r)
 => ResultsHelper.ResultToString((int[])r);
コード例 #13
0
 public override bool ResultsEqual(object a, object b)
 => ResultsHelper.ResultsEqual((int[])a, (int[])b);
コード例 #14
0
 /// <summary>
 /// Initializes the condition result set. Called from <see cref="AnalysisViewController.cs"/>
 /// </summary>
 /// <param name="cams">Cams.</param>
 /// <param name="scores">Scores.</param>
 public void InitResultSet(CAM[] cams, ScoreOutput[] scores)
 {
     this.conditionResults = ResultsHelper.BuildConditionResultArray((ChestCondition[])Enum.GetValues(typeof(ChestCondition)), scores, cams, cellColorset);
 }
コード例 #15
0
ファイル: MatchResult.cs プロジェクト: pavelsavara/nMars
 private IList<ResultsHelper> PrepareResults(IProject project, bool sort)
 {
     List<ResultsHelper> res = new List<ResultsHelper>();
     for (int w = 0; w < warriorsCount; w++)
     {
         IWarrior warrior = project.Warriors[w];
         ResultsHelper r = new ResultsHelper();
         r.originalIndex = w;
         r.score = score[w];
         r.warrior = warrior;
         res.Add(r);
     }
     if (sort)
         res.Sort();
     return res;
 }
コード例 #16
0
 public StructuredReport(PatientData patientData, ReportingOptions options)
 {
     ReportingOptions = options;
     PatientData      = patientData;
     ResultsHelper.GetEmptyResults(patientData).ForEach(x => Results.Add(x.Name, x));
 }
コード例 #17
0
            public int CompareTo(object obj)
            {
                ResultsHelper r = (ResultsHelper)obj;

                return(score.CompareTo(r.score));
            }