Example #1
0
        public ReceitaViewModel Adicionar(ReceitaViewModel receitaViewModel)
        {
            var receita = _mapper.Map <Receita>(receitaViewModel);

            var retorno = _receitaService.Create(receita);

            var viewModel = _mapper.Map <ReceitaViewModel>(retorno);

            return(viewModel);
        }
 public IActionResult Post([FromBody] Receita receita)
 {
     if (receita == null)
     {
         return(BadRequest());
     }
     else
     {
         return(new ObjectResult(_receitaService.Create(receita)));
     }
 }
Example #3
0
 public async Task <IActionResult> Create([FromForm] ReceitaInsertDto item)
 {
     try
     {
         var code = _service.Create(item);
         return(CreatedAtAction(nameof(Find), new { code }));
     }
     catch (ArgumentException ex)
     {
         return(StatusCode(400, new Error(ex.Message)));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, new Error(ex.Message)));
     }
 }
Example #4
0
        public async Task <IActionResult> SendRecipe([FromBody] BlogPost blogPost)
        {
            await Task.FromResult(_blogService.Create(blogPost));

            if (blogPost.SendNotification)
            {
                var message = new PushMessage($"Nova Receita adicionada: {blogPost.Title}")
                {
                    Topic   = "NovaReceita",
                    Urgency = PushMessageUrgency.Normal
                };

                await _pushService.SendNotificationAsync(message);
            }

            return(NoContent());
        }