コード例 #1
0
        public void CreateTruckViewModel(CreateTruckViewModel truck)
        {
            Truck tr = new Truck(truck.Chassis, truck.TruckModelId, truck.ManufactureYear, truck.ResponsableId, truck.Status);

            _contextDb.Add(tr);
            _contextDb.SaveChanges();
        }
コード例 #2
0
        public async Task CreateAsync(CreateTruckViewModel inputModel)
        {
            var truck = AutoMapperConfig.MapperInstance.Map <Truck>(inputModel);

            truck.Id = Guid.NewGuid().ToString();

            await this.trucksRepository.AddAsync(truck);

            await this.trucksRepository.SaveChangesAsync();
        }
コード例 #3
0
        public async Task <IActionResult> Create(CreateTruckViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.trucksService.CreateAsync(inputModel);

            return(this.RedirectToAction("MyTrucks"));
        }
コード例 #4
0
 public IActionResult CreateNewTruck([FromBody] CreateTruckViewModel createTruckViewModel)
 {
     try
     {
         _itruckServices.CreateTruckViewModel(createTruckViewModel);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
     return(Ok());
 }