Exemplo n.º 1
0
        public async Task <IHttpActionResult> Post([FromBody] CarViewModel car)
        {
            var result = await _carService.AddOrUpdateCar(car.ToMap <Entities.Entities.Car>());

            if (result != null)
            {
                return(Created(Request.RequestUri + result.Id.ToString(), result));
            }
            return(Conflict());
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] CarViewModel car)
        {
            var currentCar = await _carService.GetCarById(id);

            if (currentCar == null)
            {
                return(NotFound());
            }

            var result = await _carService.AddOrUpdateCar(car.ToMap <Entities.Entities.Car>());

            if (result != null)
            {
                return(Ok(result));
            }
            return(Content(HttpStatusCode.NoContent, car));
        }