Beispiel #1
0
        public async Task <IActionResult> Add([FromBody] Veiculos model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var Id = await veiculosRepository.Add(model);

                    if (Id > 0)
                    {
                        var result = new
                        {
                            code = 20000,
                            data = new
                            {
                                id     = Id,
                                mesage = "success"
                            }
                        };

                        return(Ok(result));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Beispiel #2
0
        public ActionResult Create(IFormCollection collection, Veiculo_Modelo modelo)
        {
            try
            {
                modelo.MarcaId = Convert.ToInt32(collection["Marca"]);
                _veiculoRepository.Add(modelo);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
 public Retorno AdicionarCarro(Carro carro)
 {
     return(veiculosRepository.Add(carro));
 }