コード例 #1
0
        public async ValueTask <ViewResult> List(string category)
        {
            ViewBag.Title = "Автомобили";

            var categoryType = category?.ToLowerInvariant() switch
            {
                "classic" => CategoryConsts.CategoryType.Classic,
                "electric" => CategoryConsts.CategoryType.Electric,
                _ => CategoryConsts.CategoryType.None,
            };

            IQueryable <Car> cars;

            if (categoryType != CategoryConsts.CategoryType.None)
            {
                cars = _carRepository.GetAll()
                       .Where(x => x.Category.CategoryType == categoryType);
            }
            else
            {
                cars = _carRepository.GetAll();
            }

            var carsVM = new CarsViewModel()
            {
                Cars         = await cars.ToListAsync(),
                CategoryName = CategoryConsts.Categories[categoryType].Name,
            };

            return(View(carsVM));
        }
コード例 #2
0
        public ActionResult Edit(CarsViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var Cars = CarsService.Get(model.Id);
                    AutoMapper.Mapper.Map(model, Cars);
                    SetModifier(Cars, true);
                    CarsService.Update(Cars);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    if (Request["IsPopup"] != null && Request["IsPopup"].ToString().ToLower().Equals("true"))
                    {
                        return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
                    }
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
コード例 #3
0
        public IActionResult Index(Car car)
        {
            var       sessionSortState = HttpContext.Session.GetString("SortStateCar");
            SortState sortOrder        = new SortState();

            if (sessionSortState != null)
            {
                sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
            }

            int?page = HttpContext.Session.GetInt32("CarPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("CarPage", 0);
            }

            IQueryable <Car> cars = Sort(db.Cars, sortOrder,
                                         car.Model, car.Colour,
                                         car.StateNumber, (int)page);

            HttpContext.Session.SetObject("Car", car);

            CarsViewModel carsView = new CarsViewModel
            {
                CarViewModel  = car,
                PageViewModel = cars,
                PageNumber    = (int)page
            };

            return(View(carsView));
        }
コード例 #4
0
        private async void GetCars()
        {
            CarsViewModel carsViewModel = new CarsViewModel();

            //  await carsViewModel.CarGetter();
            Cars = carsViewModel.BrickCars.ToList();
        }
コード例 #5
0
        public ActionResult CartypsAndCar()//מציג את שתי טבלאות הרכבים
        {
            List <CarsViewModel> listcvm = new List <CarsViewModel>();
            var carsfromDB = carsmanager.Cars;

            foreach (var item in carsfromDB)
            {
                CarsViewModel vm = new CarsViewModel();

                vm.TypeID               = item.Cartyp.TypeID;
                vm.Manufacturer         = item.Cartyp.Manufacturer;
                vm.Model                = item.Cartyp.Model;
                vm.Year_of_Manufacturer = item.Cartyp.Year_of_Manufacturer;
                vm.Transmission         = item.Cartyp.Transmission;
                vm.Daily_cost           = item.Cartyp.Daily_cost;
                vm.Day_late             = item.Cartyp.Day_late;

                vm.CarID            = item.CarID;
                vm.Mileage          = item.Mileage;
                vm.Picture          = item.Picture;
                vm.IsRepaired       = item.IsRepaired;
                vm.IsAvailable      = item.IsAvailable;
                vm.C_License_number = item.C_License_number;
                vm.BranchID         = item.BranchID;

                listcvm.Add(vm);
            }
            return(View(listcvm));
        }
コード例 #6
0
        public ViewResult Create(int?CustomerId)
        {
            var model = new CarsViewModel();

            model.CustomerId = CustomerId;
            return(View(model));
        }
コード例 #7
0
 public CarsPage()
 {
     viewModel = new CarsViewModel();
     viewModel.LoadCars();
     InitializeComponent();
     BindingContext = viewModel;
 }
コード例 #8
0
        public CarListPage()
        {
            InitializeComponent();
            var vm = new CarsViewModel();

            BindingContext = vm;
        }
コード例 #9
0
        public FormCars(Model model)
        {
            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            InitializeComponent();

            _model  = model;
            _bsCars = new BindingSource();
            //привязки DGV & столбцов
            _dataGridView.AutoGenerateColumns = false;
            _dataGridView.DataSource          = _bsCars;
            _columnModel.DataPropertyName     = nameof(Car.Model);
            _columnYear.DataPropertyName      = nameof(Car.Year);
            _columnTrans.DataPropertyName     = nameof(Car.Transmission);
            _columnDrive.DataPropertyName     = nameof(Car.Drive);
            _columnHp.DataPropertyName        = nameof(Car.Hp);
            _columnEngine.DataPropertyName    = nameof(Car.Engine);
            _columnPrice.DataPropertyName     = nameof(Car.Price);

            _viewModel = new CarsViewModel();
            //привязки текстбоксов цены
            _textBoxPriceFrom.DataBindings.Add("Text", _viewModel,
                                               nameof(CarsViewModel.PriceFrom), true, DataSourceUpdateMode.OnPropertyChanged);
            _textBoxPriceTo.DataBindings.Add("Text", _viewModel,
                                             nameof(CarsViewModel.PriceTo), true, DataSourceUpdateMode.OnPropertyChanged);

            //заполняем данными DGV
            _model.Cars.ForEach(c => _bsCars.Add(c));
            //подписка на изменение цены
            _viewModel.PriceChanged += ViewModel_PriceChanged;
        }
コード例 #10
0
        private async void GetCars()
        {
            CarsViewModel carsViewModel = new CarsViewModel();
            await carsViewModel.ShippingCarGetter();

            Cars = carsViewModel.ShippingCars.ToList();
        }
コード例 #11
0
        public CarsWindow(CarsViewModel carsViewModel)
        {
            ViewModel = carsViewModel;
            InitializeComponent();

            carsListBox.ItemsSource = ViewModel.Cars;
        }
コード例 #12
0
        public CarsPage()
        {
            InitializeComponent();

            // Connecting context of this page to the our View Model class
            BindingContext = new CarsViewModel();
        }
コード例 #13
0
        private async void AllStack_Tapped(object sender, EventArgs e)
        {
            Activ.IsRunning = true;
            if (ModelFrame.IsVisible == true)
            {
                ModelFrame.IsVisible  = false;
                ModelActive.IsRunning = false;
            }
            StackLayout f = (StackLayout)sender;
            string      cartypenamestring = string.Empty;
            var         fcontent          = f.Children;
            var         reqLabel          = fcontent[0];
            var         theLabel          = reqLabel.GetType();

            if (theLabel == typeof(Label))
            {
                Label emailLabel = (Label)reqLabel;
                cartypenamestring = emailLabel.Text;
                CarsViewModel cars = new CarsViewModel();
                await cars.BrickCarGetter();

                Cars            = cars.BrickCars.ToList();
                MainMap.Pins    = Cars;
                Activ.IsRunning = false;
            }
        }
コード例 #14
0
        public ActionResult Edit(Car car, int Id)
        {
            Car           carToEdit       = context.Find(Id);
            CarsViewModel viewModelToEdit = CarsViewModel.FromCar(carToEdit);

            if (carToEdit == null)
            {
                return(HttpNotFound());
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(viewModelToEdit));
                }

                carToEdit.Plate        = car.Plate;
                carToEdit.Manufacturer = car.Manufacturer;
                carToEdit.Model        = car.Model;
                carToEdit.PricePerDay  = car.PricePerDay;
                carToEdit.LocationID   = car.LocationID;

                context.Commit();

                return(RedirectToAction("Index"));
            }
        }
コード例 #15
0
        public ActionResult Create()
        {
            Car           car       = new Car();
            CarsViewModel viewModel = CarsViewModel.FromCar(car);

            viewModel.Locations = viewModel.GetLocations();
            return(View(viewModel));
        }
コード例 #16
0
 public ActionResult Create(CarsViewModel carViewModel)
 {
     if (ModelState.IsValid)
     {
         _repository.Add(carViewModel.Model, carViewModel.Name, carViewModel.Year);
     }
     return(View("Index", CreateView()));
 }
コード例 #17
0
        private async void namelblTabbed(object sender, EventArgs e)
        {
            MainMap.Pins = null;
            Label         Alllbl = (Label)sender;
            string        citem  = Alllbl.Text;
            CarsViewModel cars   = new CarsViewModel();
            await cars.BrickCarGetter();

            MainMap.Pins = cars.BrickCars.Where(o => o.cartypename == citem).ToList();
        }
コード例 #18
0
        private async void All_Tapped(object sender, EventArgs e)
        {
            Label         Alllbl = (Label)sender;
            string        citem  = Alllbl.Text;
            CarsViewModel cars   = new CarsViewModel();
            await cars.BrickCarGetter();

            Cars         = cars.BrickCars.ToList();
            MainMap.Pins = Cars;
        }
コード例 #19
0
        public IActionResult CarViewList(int companyId)
        {
            var model             = new CarsViewModel();
            var cars              = new CarDb(_config).getCars(companyId);
            var companyNameFromDB = new SettingsDb(_config).GetCompanyName(companyId);

            model.Cars        = cars;
            model.companyName = companyNameFromDB;

            return(View(model));
        }
コード例 #20
0
ファイル: CarsController.cs プロジェクト: wladcy/Distance
 public ActionResult Index()
 {
     CarsViewModel model = new CarsViewModel();
     model.IsAdministrator = IsAdministrator();
     DatabaseControler dc = new DatabaseControler();
     var userName = User.Identity.Name;
     ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
     var user = userManager.FindByName(userName);
     model.IsSetCompany = dc.IsSetCompany(user.Id);
     model.CarList = dc.GetAllCars(user);
     return View(model);
 }
コード例 #21
0
        // GET: Administrator
        public ActionResult Index()
        {
            List <Car> Cars = new List <Car>();

            Cars = db.Cars.ToList();


            CarsViewModel vm = new CarsViewModel();


            vm.AllCarsList = Cars;
            return(View(vm));
        }
コード例 #22
0
        public async Task <IActionResult> Index()
        {
            // Get to-do items from database
            var items = await _CarModelService.GetNewModelAsync();

            // Put items into a model
            var model = new CarsViewModel()
            {
                Models = Models
            };

            // Render view using the model
            return(View(model));
        }
コード例 #23
0
ファイル: CarController.cs プロジェクト: dendiod/RentC
        public ActionResult AvailableCars(CarsViewModel<localhost.QueryCar> viewModel, string orderBy = "Id")
        {
            if (!ModelState.IsValid)
            {
                return View(new CarsViewModel<localhost.QueryCar>() { Cars = new List<localhost.QueryCar>() });
            }
            localhost.QueryCar car = viewModel.SearchCar ?? new localhost.QueryCar();
            localhost.AvailableCarsService webService = new localhost.AvailableCarsService();
            localhost.QueryCar[] cars = webService.GetAvailableCars(orderBy, car);

            viewModel.Cars = cars;

            return View(viewModel);
        }
コード例 #24
0
        public ActionResult Cars(CarsViewModel vm)
        {
            Debug.WriteLine(vm.minKM);
            Debug.WriteLine(vm.maxKM);
            Debug.WriteLine(vm.minPrice);
            Debug.WriteLine(vm.maxPrice);

            List <tblCars> cars = new List <tblCars>();

            tblCarsService   service    = new tblCarsService();
            tblColorsService colservice = new tblColorsService();
            tblBrandsService bservice   = new tblBrandsService();

            cars = service.getAllCars().ToList();
            if (vm.selectedBrandId != 0)
            {
                cars = service.FilterByBrand(cars, bservice.getBrands().ElementAt(vm.selectedBrandId - 2)).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.selectedColorId != 0)
            {
                cars = service.FilterByColor(cars, colservice.getColors().ElementAt(vm.selectedColorId - 1)).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.transmissionChoice == Transmission.Automaat || vm.transmissionChoice == Transmission.Manueel)
            {
                cars = cars.Where(a => a.Transmission == vm.transmissionChoice.ToString()).ToList();
                Debug.WriteLine(cars.Count());
            }
            if (vm.fuelChoice == Fuel.Benzine || vm.fuelChoice == Fuel.Diesel || vm.fuelChoice == Fuel.Elektrisch || vm.fuelChoice == Fuel.Hybride || vm.fuelChoice == Fuel.LPG)
            {
                cars = cars.Where(a => a.CarFuel == vm.fuelChoice.ToString()).ToList();
                Debug.WriteLine(cars.Count());
            }
            cars = service.FilterByKM(cars, vm.minKM, vm.maxKM).ToList();
            Debug.WriteLine(cars.Count());
            cars = service.FilterByPrice(cars, Convert.ToInt32(vm.minPrice), Convert.ToInt32(vm.maxPrice)).ToList();
            Debug.WriteLine(cars.Count());

            vm.cars        = cars;
            vm.minKM       = service.getAllCars().Min(a => a.CarKilometers);
            vm.maxKM       = service.getAllCars().Max(a => a.CarKilometers);
            vm.minPrice    = service.getAllCars().Min(b => b.CarPrice);
            vm.maxPrice    = service.getAllCars().Max(b => b.CarPrice);
            vm.brandChoice = bservice.getBrands();
            vm.colorChoice = colservice.getColors();
            vm.images      = service.getAllImages();
            vm.CarsInStock = service.getAllCars().Where(a => a.Sold == 0).Count();
            return(View(vm));
        }
コード例 #25
0
ファイル: CarController.cs プロジェクト: dendiod/RentC
        public ActionResult RentedCarsInMonth(CarsViewModel<QueryCar> viewModel, string orderBy = "ReservationsCount")
        {
            if (!ModelState.IsValid)
            {
                return View(new CarsViewModel<QueryCar>() { Cars = new List<QueryCar>() });
            }
            QueryCar car = viewModel.SearchCar ?? new QueryCar();
            QueryManager queryManager = new QueryManager(carRepo, customerRepo, reservationRepo, locationRepo,
                modelRepo, manufacturerRepo);
            QueryCar[] cars = queryManager.GetCarsInMonth(orderBy, car);

            viewModel.Cars = cars;

            return View(viewModel);
        }
コード例 #26
0
        private async void GetCars()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                CarsViewModel cars = new CarsViewModel();
                await cars.BrickCarGetter();

                Cars          = cars.BrickCars.ToList();
                CarsTypeBrick = cars.CarTypesBrick.ToList();
            }
            else
            {
                Errorlbl.IsVisible = true;
                Errorlbl.Text      = AppResources.ErrorMessage;
            }
        }
コード例 #27
0
        public ActionResult Edit(int Id)
        {
            Car           car       = context.Find(Id);
            CarsViewModel viewModel = CarsViewModel.FromCar(car);

            viewModel.Locations = viewModel.GetLocations();

            if (car == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(viewModel));
            }
        }
コード例 #28
0
 public ActionResult Create(CarsViewModel model)
 {
     if (ModelState.IsValid)
     {
         var Cars = new Cars();
         AutoMapper.Mapper.Map(model, Cars);
         SetModifier(Cars);
         CarsService.Create(Cars);
         TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
         if (Request["IsPopup"] != null && Request["IsPopup"].ToString().ToLower().Equals("true"))
         {
             return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #29
0
        private async void StackTapped(object sender, EventArgs e)
        {
            Activ.IsRunning = true;
            if (ModelFrame.IsVisible != true)
            {
                ModelFrame.IsVisible  = true;
                ModelActive.IsRunning = true;
            }
            StackLayout f = (StackLayout)sender;
            string      cartypenamestring = string.Empty;
            var         fcontent          = f.Children;
            var         reqLabel          = fcontent[0];
            var         theLabel          = reqLabel.GetType();

            if (theLabel == typeof(Label))
            {
                Label emailLabel = (Label)reqLabel;
                cartypenamestring = emailLabel.Text;
                CarsViewModel cars = new CarsViewModel();
                await cars.ShippingCarGetter();

                Cars = cars.ShippingCars.Where(o => o.cartypename == cartypenamestring).ToList();
                if (Cars.Count() == 0)
                {
                    Pinslbl.IsVisible = false;
                    MainMap.Pins      = Cars;
                }
                else
                {
                    Pinslbl.IsVisible = true;
                }
                CarsType = cars.CarTypes.Where(o => o.name == cartypenamestring).ToList();
                foreach (var item in CarsType)
                {
                    var CarModelList = item.carmodals;
                    foreach (var modelitem in CarModelList)
                    {
                        var ModelIcon = modelitem.icon;
                        modelitem.icon = "http://waselksa.alsalil.net/users/images/" + ModelIcon;
                    }
                    Modellist.ItemsSource = CarModelList;
                    ModelActive.IsRunning = false;
                }
            }
        }
コード例 #30
0
        public ActionResult Create(CarsViewModel mod)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var car = Mapper.Map <CarsViewModel, Cars>(mod);

                    _unitOfWork.RepositoryFor <Cars, int>().Create(car);
                    _unitOfWork.Commit();
                    return(RedirectToRoute(new { controller = "Clients", action = "Details", id = mod.ClientsID }));
                }
            }
            catch (DataException)
            {
                throw;
            }
            return(View());
        }