public async Task <int> Post([FromBody] Car car) { using (_logger.BeginScope($"creating car. {car.Name}")) { return(await _carService.AddAsync(car)); } }
public async Task <ActionResult> Add([Bind(Include = "CarId,CarModel,CarMaker,CarYearOfProduction,CarKilometers,CarPrice,CarDescription")] CarViewModel viewModel) { if (ModelState.IsValid) { await Service.AddAsync(AutoMapper.Mapper.Map <ICars>(viewModel)); return(RedirectToAction("Index")); } return(View(viewModel)); }
public async Task <IActionResult> Add(CarAddDto addDto) { var result = await _carService.AddAsync(_mapper.Map <Car>(addDto)); if (result.Success) { return(Created("", result)); } return(BadRequest(result)); }
public async Task <IActionResult> Create([Bind("Brand,Model,Color,Billede")] CarViewModel car) { if (ModelState.IsValid) { await _carService.AddAsync(Mapper.Map(car)).ConfigureAwait(false); return(RedirectToAction(nameof(Index))); } return(View(car)); }
public async Task <IActionResult> AddAsync(CarAddDto carAddDto) { var result = await _carService.AddAsync(carAddDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Create(Car car) { if (ModelState.IsValid) { car.UserId = new Guid(_userManager.GetUserId(HttpContext.User)); await _carService.AddAsync(car); return(RedirectToAction(nameof(Index))); } return(View(car)); }
public async Task <ActionResult <Car> > Post([FromBody] Car Car) { if (ModelState.IsValid) { var result = await _carService.AddAsync(Car); return(CreatedAtAction(nameof(Get), new { id = result.Id }, result)); } else { return(BadRequest()); } }
public async Task <ActionResult> Post([FromBody] CarDto carDto) { try { if (carDto == null) { return(BadRequest($"{nameof(carDto)} can not not be null!")); } await _carService.AddAsync(carDto); return(Ok()); } catch (Exception e) { return(BadRequest(e)); } }
public async Task HandleAsync(AddVehicle command) { if (command.Images != null) { AddImageToCar.Add(_hostingEnvironment, command.Images, command.Car); } if (!command.Car.Milage.Contains("km")) { command.Car.Milage += " km"; } if (!command.Car.Power.Contains("KM")) { command.Car.Power += " KM"; } await _carService.AddAsync(command.Car); }
public async Task <IHttpActionResult> PostCar(CarDto carDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Car car = new Car(); Mapper.Map(carDto, car); car.ApplicationUserId = User.Identity.GetUserId(); car = await _carService.AddAsync(car); carDto.CarId = car.Id; return(CreatedAtRoute("ApiRoute", new { id = carDto.CarId }, carDto)); }
public async Task <IActionResult> Save(CarDto carDto) { var car = await _carService.AddAsync(_mapper.Map <Car>(carDto)); return(Created(string.Empty, _mapper.Map <CarDto>(car))); }