コード例 #1
0
ファイル: LoadsController.cs プロジェクト: Dimitrix85/STEU
        public async Task <IActionResult> CreateLoad(AddLoadInputModel model)
        {
            if (this.ModelState.IsValid == false)
            {
                var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresCreateLoadViewModel>();

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

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

                LoadCreateViewModel inputModel = new LoadCreateViewModel()
                {
                    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 LoadCreateViewModel();
            await this.loadsService.CreateLoadAsync(model, userId);

            return(this.Redirect("/Loads/AllLoads"));
        }
コード例 #2
0
ファイル: LoadsController.cs プロジェクト: Dimitrix85/STEU
        public async Task <IActionResult> CreateLoad()
        {
            var countries = await this.countriesService.GetAllCountriesAsync <AllCountiresCreateLoadViewModel>();

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

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

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

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

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

            model.Referer = referer;

            return(this.View(model));
        }