public ActionResult List(int id)
        {
            var service = CreatePlanetService();
            var list    = service.GetPlanetById(id);
            var model   =
                new PlanetListItems
            {
                PlanetId      = list.PlanetId,
                PlanetaryName = list.PlanetaryName,
                NumOfBadGuys  = list.NumOfBadGuys
            };

            return(RedirectToAction("List"));
        }
Exemplo n.º 2
0
        public List <PlanetListItems> GetPlanets()
        {
            using (var ctx = new ApplicationDbContext())
            {
                var planetentity = ctx.Planets;

                var planetListItems = new List <PlanetListItems>();

                foreach (var item in planetentity)
                {
                    var projectListItem = new PlanetListItems()
                    {
                        PlanetId      = item.PlanetId,
                        PlanetaryName = item.PlanetaryName,
                        NumOfBadGuys  = item.NumOfBadGuys
                    };

                    planetListItems.Add(projectListItem);
                }

                return(planetListItems);
            }
        }