public async Task <IActionResult> Create([FromBody] CarSaveView carBody) { try { var car = new Car() { Board = carBody.Board, HourPrice = carBody.HourPrice, LuggageCapacity = carBody.LuggageCapacity, TankCapacity = carBody.TankCapacity, IdBrand = carBody.IdBrand, IdCategory = carBody.IdCategory, IdFuel = carBody.IdFuel, IdModel = carBody.IdModel }; await _save.Execute(car); return(StatusCode(201)); } catch (CarExistException err) { return(StatusCode(401, new { Message = err.Message })); } }
public async Task <IActionResult> Create([FromBody] CarSaveView carBody) { try { carBody.Photos = carBody.Images.Count > 1 ? string.Join(',', carBody.Images) : carBody.Images[0]; carBody.Images = null; var car = EntityBuilder.Call <Car>(carBody); await _save.Execute(car); return(StatusCode(201)); } catch (CarExistException err) { return(StatusCode(401, new { Message = err.Message })); } }