Exemplo n.º 1
0
        public void CreateWish(WishCreateDTO wish)
        {
            if (string.IsNullOrEmpty(wish.descwish))
            {
                throw new Exception("Informações de cadastros inválidas");
            }

            Wish newWish = new Wish()
            {
                Descwish   = wish.descwish,
                IdUsuario  = wish.IdUsuario,
                Creationdt = DateTime.Now,
                Ativo      = true
            };

            _repository.CreateWish(newWish);
        }
Exemplo n.º 2
0
        public IActionResult CreateWish(WishCreateDTO wish)
        {
            try
            {
                WishCreateDTO newWish = new WishCreateDTO();
                try
                {
                    newWish.IdUsuario = Convert.ToInt32(HttpContext.User.Claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value);
                }catch (Exception ex)
                {
                    throw new Exception("Erro no carregamento, usuário não encontrado");
                }
                newWish.descwish = wish.descwish;
                _service.CreateWish(newWish);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }