Exemplo n.º 1
0
        public IActionResult saveToken()
        {
            try
            {
                Tokens token     = new Tokens();
                var    idCompany = SecurityBusiness.IdCompany(HttpContext);
                var    idUser    = SecurityBusiness.IdUser(HttpContext);

                if (idCompany == 0)
                {
                    return(BadRequest(new{
                        errorMessage = "Empresa não encontrada."
                    }));
                }

                token.active         = true;
                token.createdat      = DateTime.Now;
                token.code           = Guid.NewGuid();
                token.fk_company     = idCompany;
                token.fk_user_create = idUser;
                _csxContext.Tokens.Add(token);
                _csxContext.SaveChanges();

                return(Ok(token));
            }
            catch (System.Exception ex)
            {
                return(NotFound("Erro ao Salvar: " + ex.Message));
            }
        }
Exemplo n.º 2
0
        public IActionResult UserDetail()
        {
            var id         = SecurityBusiness.IdUser(HttpContext);
            var id_company = SecurityBusiness.IdCompany(HttpContext);

            return(Ok(new {
                id = id,
                companyId = id_company,
                name = User.Identity.Name
            }
                      ));
        }