public async Task <IActionResult> Add(Vehicle vehicle) { //if (!ModelState.IsValid) // return View(vehicle); await _vehicleService.AddAsync(vehicle); return(RedirectToAction("List")); }
public async Task <ActionResult <VehicleDto> > Create(CreatingVehicleDto obj) { var dto = VehicleMapper.toDTO(obj); var vehicle = await _service.AddAsync(dto); return(CreatedAtAction(nameof(GetGetById), new { Id = vehicle.Id }, vehicle)); }
private async Task AddVehicleAsync() { if (ValidateModel()) { await _vehicleService.AddAsync(Model); BackFromActualPage(); } }
private void AddVehicle() { var drivers = _userService.GetAllDrivers(); if (drivers.Count < 1) { Console.WriteLine(); _ioHelper.WriteString("It is not possible to add vehicle - minimum 1 driver needed"); return; } var driverId = _ioHelperAddVehicle.SelectDriverId(drivers); var vehicle = _ioHelperAddVehicle.CreateNewVehicle(driverId); _vehicleService.AddAsync(vehicle).Wait(); }
public async Task <IActionResult> PostAsync([FromBody] VehicleModel model) { try { await _vehicleService.AddAsync(model, Guid.Parse(User.Identity.Name)); return(Ok()); } catch (CustomExceptions ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <ActionResult <Vehicle> > Post(Vehicle vehicle) { await _vehicleService.AddAsync(vehicle); return(Ok(vehicle)); }
public async Task PostVehicleAsync([FromBody] Vehicle vehicle) { await _vehicleService.AddAsync(vehicle); }