public IActionResult Post([FromBody] AddCostumerInputModel model) { var costumer = new Customer(model.FullName, model.Document, model.BirthDate); _dbContext.Customers.Add(costumer); _dbContext.SaveChanges(); return(NoContent()); }
public IActionResult Post([FromBody] AddCarInputModel model) { if (model.Model.Length > 50) { return(BadRequest("Modelo não pode ter mais de 50 caracteres")); } var car = new Car(model.VinCode, model.Brand, model.Model, model.Year, model.Price, model.Color, model.ProductionDate); _dbContext.Cars.Add(car); _dbContext.SaveChanges(); return(CreatedAtAction( nameof(GetById), new { id = car.Id }, model )); }