示例#1
0
        // DELETE /webpages_RoleLevels/token/LevelId
        public HttpResponseMessage Delete(string token, Int32 LevelId)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    HttpResponseMessage retorno = new HttpResponseMessage();

                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("LevelId : " + LevelId), "Delete", _db);

                    if (Permissoes.Autenticado(token, _db))
                    {
                        GatewayWebpagesRoleLevels.Delete(token, LevelId, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }