Esempio n. 1
0
        public ResponseEnvelope <string> Response(ObterURLResponse response)
        {
            var envelope = new ResponseEnvelope <string>(string.Empty);

            envelope.HttpStatusCode = (HttpStatusCode)response.HttpStatusCode;

            if (envelope.Success)
            {
                envelope.Item = response.URL;
            }
            else
            {
                envelope.Error.Messages.Add(response.Erro);
            }

            return(envelope);
        }
        public override async Task <ObterURLResponse> ObterURL(ObterURLRequest request, ServerCallContext context)
        {
            var response = new ObterURLResponse();

            try
            {
                var empresaId = Guid.Parse(request.EmpresaId);

                var envelope = await oauthServico.Authenticate(empresaId, request.ContaRedeSocial);

                response.URL = envelope.Item;

                response.HttpStatusCode = (int)HttpStatusCode.Created;
            }
            catch (Exception ex)
            {
                response.HttpStatusCode = (int)HttpStatusCode.InternalServerError;
                response.Erro           = ex.Message;
            }

            return(response);
        }