public IActionResult Details(int id)
        {
            var stc  = new SharpTrooper.Core.SharpTrooperCore("https://swapi.dev/api", null);
            var data = stc.GetAllFilms().results.FirstOrDefault(e => e.episode_id == id);

            if (data == null)
            {
                return(NotFound());
            }
            return(View(data));
        }
        public FilmsListViewModel(MyDbContext db)
        {
            FilmsList = new List <KeyValuePair <SharpTrooper.Entities.Film, double> >();
            var stc = new SharpTrooper.Core.SharpTrooperCore("https://swapi.dev/api", null);

            foreach (var _film in stc.GetAllFilms().results)
            {
                var    _counter = db.FilmRating.Where(e => e.FilmId == _film.episode_id).Count();
                double _rating  = -1;

                if (_counter > 0)
                {
                    _rating = (double)db.FilmRating.Where(e => e.FilmId == _film.episode_id).Sum(e => e.Rate) / (double)_counter;
                }

                FilmsList.Add(new KeyValuePair <SharpTrooper.Entities.Film, double>(_film, _rating));
            }
        }
Exemple #3
0
 public void DllConnectionTest()
 {
     var stc          = new SharpTrooper.Core.SharpTrooperCore("https://swapi.dev/api", null);
     var films        = stc.GetAllFilms();
     var allstarships = stc.GetAllStarships();
 }