Exemplo n.º 1
0
        public async Task <TestDetail> Add(TestDetail NewAthlete)
        {
            if (NewAthlete.Distance <= 1000)
            {
                NewAthlete.Rating = "Below average";
            }
            else if (NewAthlete.Distance <= 2000)
            {
                NewAthlete.Rating = "Average";
            }
            else if (NewAthlete.Distance <= 3500)
            {
                NewAthlete.Rating = "Good";
            }
            else if (NewAthlete.Distance > 3500)
            {
                NewAthlete.Rating = "Very good";
            }
            await _context.TestDetail.AddAsync(NewAthlete);

            return(NewAthlete);
        }
Exemplo n.º 2
0
        public TestDetail Update(TestDetail UpdatedTestDetail)
        {
            if (UpdatedTestDetail.Distance <= 1000)
            {
                UpdatedTestDetail.Rating = "Below average";
            }
            else if (UpdatedTestDetail.Distance <= 2000)
            {
                UpdatedTestDetail.Rating = "Average";
            }
            else if (UpdatedTestDetail.Distance <= 3500)
            {
                UpdatedTestDetail.Rating = "Good";
            }
            else if (UpdatedTestDetail.Distance > 3500)
            {
                UpdatedTestDetail.Rating = "Very good";
            }
            var t = _context.TestDetail.Attach(UpdatedTestDetail);

            t.State = EntityState.Modified;
            return(UpdatedTestDetail);
        }