public RetornoModel <Login, enumClienteException> PostAuth([FromBody] ClienteAuthRequestModel obj) { RetornoModel <Login, enumClienteException> retorno; if (obj != null && obj.username != null && obj.password != null) { using (ClienteBO clienteBO = new ClienteBO(SessionModel.GetSiteId())) { try { retorno = clienteBO.LogarOsesp(obj.username, obj.password); } catch (Exception ex) { retorno = new RetornoModel <Login, enumClienteException>(); retorno.Mensagem = ex.Message; retorno.Sucesso = false; LogUtil.Error(ex); throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ParseRetorno(retorno))); } if (!retorno.Sucesso) { NewRelicIgnoreTransaction(); throw new HttpResponseException(Request.CreateResponse((HttpStatusCode)422, ParseRetorno(retorno))); } else { try { // Guarda o cliente logado na sessao SessionModel.ClienteID = retorno.Retorno.ClienteID; SessionModel.SiteID = retorno.Retorno.SiteID; return(ParseRetorno(retorno)); } catch (Exception ex) { retorno = new RetornoModel <Login, enumClienteException>(); retorno.Mensagem = ex.Message; retorno.Sucesso = false; LogUtil.Error(ex); throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ParseRetorno(retorno))); } } } } else { retorno = new RetornoModel <Login, enumClienteException>(); retorno.Mensagem = "Objeto Auth não encontrado ou mal formatado"; retorno.Sucesso = false; NewRelicIgnoreTransaction(); throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest, ParseRetorno(retorno))); } }