Exemplo n.º 1
0
        public async Task <IActionResult> Add(Vehicle vehicle)
        {
            //if (!ModelState.IsValid)
            //    return View(vehicle);
            await _vehicleService.AddAsync(vehicle);

            return(RedirectToAction("List"));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        private async Task AddVehicleAsync()
        {
            if (ValidateModel())
            {
                await _vehicleService.AddAsync(Model);

                BackFromActualPage();
            }
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        public async Task <ActionResult <Vehicle> > Post(Vehicle vehicle)
        {
            await _vehicleService.AddAsync(vehicle);

            return(Ok(vehicle));
        }
Exemplo n.º 7
0
 public async Task PostVehicleAsync([FromBody] Vehicle vehicle)
 {
     await _vehicleService.AddAsync(vehicle);
 }