Esempio n. 1
0
        public async Task <IActionResult> CreateTruck(AddTrucksInputModel model)
        {
            if (this.ModelState.IsValid == false)
            {
                var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresCreateTruckViewModel>();

                var priorityTypes = await this.priorityTypesService.GetAllPriorityAsync <AllPriorityTruckCreateViewModel>();

                var truckTypes = await this.truckTypesService.GetAllTruckTypesAsync <AllTruckTypesTruckCreateViewModel>();

                TruckCreateViewModel inputModel = new TruckCreateViewModel()
                {
                    Countries  = countries,
                    Priorities = priorityTypes,
                    TruckTypes = truckTypes,
                };

                model.InputModel = inputModel;

                return(this.View(model));
            }

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            model.SteuUserId = userId;
            model.InputModel = new TruckCreateViewModel();
            await this.trucksService.CreateTruckAsync(model, userId);

            model.SteuUserId = userId;

            return(this.Redirect("/Trucks/AllTrucks"));
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateTruck()
        {
            var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresCreateTruckViewModel>();

            var priorityTypes = await this.priorityTypesService.GetAllPriorityAsync <AllPriorityTruckCreateViewModel>();

            var truckTypes = await this.truckTypesService.GetAllTruckTypesAsync <AllTruckTypesTruckCreateViewModel>();

            TruckCreateViewModel inputModel = new TruckCreateViewModel()
            {
                Countries  = countries,
                Priorities = priorityTypes,
                TruckTypes = truckTypes,
            };

            AddTrucksInputModel model = new AddTrucksInputModel()
            {
                InputModel = inputModel,
            };

            string referer = this.Request.Headers["Referer"].ToString();

            model.Referer = referer;

            return(this.View(model));
        }