public void CreateTruckViewModel(CreateTruckViewModel truck) { Truck tr = new Truck(truck.Chassis, truck.TruckModelId, truck.ManufactureYear, truck.ResponsableId, truck.Status); _contextDb.Add(tr); _contextDb.SaveChanges(); }
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(); }
public async Task <IActionResult> Create(CreateTruckViewModel inputModel) { if (!this.ModelState.IsValid) { return(this.View(inputModel)); } await this.trucksService.CreateAsync(inputModel); return(this.RedirectToAction("MyTrucks")); }
public IActionResult CreateNewTruck([FromBody] CreateTruckViewModel createTruckViewModel) { try { _itruckServices.CreateTruckViewModel(createTruckViewModel); } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok()); }