Загрузка данных


using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using MovieCatalog.Models;

namespace MovieCatalog.Controllers
{
    public class MoviesController : Controller
    {
        private static List<Film> films = new List<Film>
        {
            new Film
            {
                Id = 1,
                Title = "Интерстеллар",
                Genre = "Фантастика",
                Year = 2014,
                Rating = 8.7m
            },

            new Film
            {
                Id = 2,
                Title = "Начало",
                Genre = "Фантастика",
                Year = 2010,
                Rating = 8.8m
            },

            new Film
            {
                Id = 3,
                Title = "Зелёная книга",
                Genre = "Драма",
                Year = 2018,
                Rating = 8.3m
            },

            new Film
            {
                Id = 4,
                Title = "Джентльмены",
                Genre = "Комедия",
                Year = 2019,
                Rating = 8.0m
            },

            new Film
            {
                Id = 5,
                Title = "Марсианин",
                Genre = "Фантастика",
                Year = 2015,
                Rating = 8.0m
            }
        };

        public ActionResult Index()
        {
            return View(films);
        }

        public ActionResult Details(int id)
        {
            Film film = films.FirstOrDefault(x => x.Id == id);

            if (film == null)
            {
                return HttpNotFound();
            }

            return View(film);
        }

        [HttpGet]
        public ActionResult Create()
        {
            return View();
        }
    }
}