示例#1
0
        public IActionResult PlaneCreate(Plane entity)
        {
            if (ModelState.IsValid)
            {
                planeRepository.AddPlane(entity);
                return(RedirectToAction("PlaneList"));
            }

            return(View(entity));
        }
        public ActionResult AddPlaneToReposiotry(string NazwaSamolotu, string Przebieg, string Name, string Nickname)
        {
            Plane samolot = new Plane();

            samolot.Nazwa = NazwaSamolotu.Replace(" ", "_");
            int outs;

            Int32.TryParse(Przebieg, out outs);
            samolot.WylataneGodziny = outs;

            repository.AddPlane(samolot);

            PlaneListViewModel viewModel = new PlaneListViewModel
            {
                Name     = Name,
                NickName = Nickname
            };

            TempData["addplanemessage"] = "Poprawnie dodano samolot o nazwie " + samolot.Nazwa.Replace("_", " ") + " o przebiegu wynoszącym " + samolot.WylataneGodziny + " godzin.";

            return(View("AddPlane", viewModel));
        }