• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davewalker5 / ADS-B-BaseStationReader / 17912040583

22 Sep 2025 10:13AM UTC coverage: 78.463% (-8.3%) from 86.778%
17912040583

push

github

web-flow
Merge pull request #46 from davewalker5/reference-data-import

Reference data import

398 of 591 branches covered (67.34%)

Branch coverage included in aggregate %.

39 of 222 new or added lines in 16 files covered. (17.57%)

1 existing line in 1 file now uncovered.

1613 of 1972 relevant lines covered (81.8%)

39.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.23
/src/BaseStationReader.BusinessLogic/Database/ModelManager.cs
1
using BaseStationReader.Data;
2
using BaseStationReader.Entities.Interfaces;
3
using BaseStationReader.Entities.Lookup;
4
using Microsoft.EntityFrameworkCore;
5
using System.Linq.Expressions;
6

7
namespace BaseStationReader.BusinessLogic.Database
8
{
9
    public class ModelManager : IModelManager
10
    {
11
        private readonly BaseStationReaderDbContext _context;
12

13
        public ModelManager(BaseStationReaderDbContext context)
22✔
14
        {
22✔
15
            _context = context;
22✔
16
        }
22✔
17

18
        /// <summary>
19
        /// Return a model by either ICAO or IATA code, whichever is specified
20
        /// </summary>
21
        /// <param name="iata"></param>
22
        /// <param name="icao"></param>
23
        /// <returns></returns>
24
        public async Task<Model> GetByCodeAsync(string iata, string icao)
25
        {
13✔
26
            Model model = null;
13✔
27

28
            if (!string.IsNullOrEmpty(icao))
13!
29
            {
13✔
30
                model = await GetAsync(x => x.ICAO == icao);
13✔
31
            }
13✔
NEW
32
            else if (!string.IsNullOrEmpty(iata))
×
NEW
33
            {
×
NEW
34
                model = await GetAsync(x => x.IATA == iata);
×
NEW
35
            }
×
36

37
            return model;
13✔
38
        }
13✔
39

40
        /// <summary>
41
        /// Get the first aircraft model matching the specified criteria
42
        /// </summary>
43
        /// <param name="predicate"></param>
44
        /// <returns></returns>
45
        public async Task<Model> GetAsync(Expression<Func<Model, bool>> predicate)
46
        {
16✔
47
            List<Model> models = await ListAsync(predicate);
16✔
48
            return models.FirstOrDefault();
16✔
49
        }
16✔
50

51
        /// <summary>
52
        /// Return all aircraft models matching the specified criteria
53
        /// </summary>
54
        /// <param name="predicate"></param>
55
        /// <returns></returns>
56
        public async Task<List<Model>> ListAsync(Expression<Func<Model, bool>> predicate)
57
            => await _context
19✔
58
                .Models
19✔
59
                .Where(predicate)
19✔
60
                .Include(x => x.Manufacturer)
19✔
61
                .ToListAsync();
19✔
62

63
        /// <summary>
64
        /// Add a new model to the database
65
        /// </summary>
66
        /// <param name="template"></param>
67
        /// <returns></returns>
68
        public async Task<Model> AddAsync(string iata, string icao, string name, int manufacturerId)
69
        {
12✔
70
            var model = await GetByCodeAsync(iata, icao);
12✔
71
            if (model == null)
12✔
72
            {
11✔
73
                model = new Model
11✔
74
                {
11✔
75
                    IATA = iata,
11✔
76
                    ICAO = icao,
11✔
77
                    Name = name,
11✔
78
                    ManufacturerId = manufacturerId
11✔
79
                };
11✔
80
                await _context.Models.AddAsync(model);
11✔
81
                await _context.SaveChangesAsync();
11✔
82
            }
11✔
83

84
            return model;
12✔
85
        }
12✔
86
    }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc