コード例 #1
0
        public IActionResult Post([FromBody] ReceitaAdd vmodel)
        {
            try
            {
                _receitaService.Add(vmodel);
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok(vmodel));
        }
コード例 #2
0
        public IActionResult Add(ReceitaAdd vmodel, IFormFile image)
        {
            vmodel.Imagem = ConvetToByteArray(image);

            _receitaService.Add(vmodel);

            AddMessages();

            if (ValidOperation())
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.Categorias   = _categoriaService.ListDropDown();
            ViewBag.Ingredientes = _ingredienteService.ListDropDown();

            return(View(vmodel));
        }
コード例 #3
0
 public ActionResult <Receita> Add([FromBody] Receita receita)
 {
     return(Created("", _service.Add(receita)));
 }