Пример #1
0
        // GET: Drivers/Edit/5
        public ActionResult Edit(int id)
        {
            sqlconn.Open();
            UserDriver driver = UserDriverLogic.FindById(sqlconn, id);

            sqlconn.Close();
            return(View(driver));
        }
Пример #2
0
        // GET: Drivers
        public ActionResult Index()
        {
            sqlconn.Open();
            List <UserDriver> drivers = UserDriverLogic.FindAll(sqlconn);

            sqlconn.Close();
            return(View(drivers));
        }
Пример #3
0
        // GET: Vehicles/Create
        public ActionResult Create()
        {
            sqlconn.Open();
            List <VehicleType>  types  = VehicleTypeXmlMapper.SelectAll();
            List <VehicleBrand> brands = VehicleBrandXmlMapper.SelectAll();

            List <UserDriver> drivers = UserDriverLogic.FindAll(sqlconn);
            List <UserBoss>   bosses  = UserBossLogic.FindAll(sqlconn);

            sqlconn.Close();

            ViewData["vehicleTypes"]  = types;
            ViewData["vehicleBrands"] = brands;
            ViewData["drivers"]       = drivers;
            ViewData["bosses"]        = bosses;

            return(View());
        }
Пример #4
0
        public ActionResult Edit(int id, UserDriver driver)
        {
            try
            {
                sqlconn.Open();
                int result = UserDriverLogic.Update(sqlconn, driver);
                sqlconn.Close();

                if (result != 0)
                {
                    throw new Exception();
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(driver));
            }
        }