Ejemplo n.º 1
0
 public void AdicionarPerfil(Perfil administrador)
 {
     if (Aplicacao.TemEssePerfil(administrador))
     {
         Perfis.Add(administrador);
     }
 }
Ejemplo n.º 2
0
 public void AdicionarPerfil(Perfil perfil)
 {
     if (!TemEssePerfil(perfil))
     {
         Perfis.Add(perfil);
     }
 }
Ejemplo n.º 3
0
        public BaseReturn CadastrarLogin(int codigousuario, string login, string senha, string senhaantiga, int codigoperfil)
        {
            if (PesquisarLogin(login).FirstOrDefault() != null)
            {
                return(new BaseReturn("Login", Library.Class.Resources.Message.JA_EXISTE_UM_X0_CHAMADO_X1.ToFormat("Login", login), false));
            }

            Usuarios DadosUsuarios = _RepositoryUsuario.Find(codigousuario);

            if (DadosUsuarios.IsInvalid())
            {
                return(new BaseReturn(DadosUsuarios.Notifications.FirstOrDefault().Property, DadosUsuarios.Notifications.FirstOrDefault().Message, false));
            }

            Logins DadosLogin = new Logins(login, senha, senhaantiga);

            if (DadosLogin.IsInvalid())
            {
                return(new BaseReturn(DadosLogin.Notifications.FirstOrDefault().Property, DadosLogin.Notifications.FirstOrDefault().Message, false));
            }

            Perfis DadosPerfis = _RepositoryPerfi.Find(codigoperfil);

            DadosPerfis.Login.Add(DadosLogin);

            _RepositoryPerfi.Edit(DadosPerfis);


            DadosUsuarios.AlterarUsuarios(DadosLogin);

            _RepositoryUsuario.Edit(DadosUsuarios);

            return(new BaseReturn("Login", Library.Class.Resources.Message.OPERACAO_REALIZADA_COM_SUCESSO, true));
        }
Ejemplo n.º 4
0
 public void AdicionarPerfil(Perfil administrador)
 {
     if (!Contratante.TemEssePerfil(administrador))
     {
         Perfis.Add(administrador);
     }
 }
Ejemplo n.º 5
0
        protected void linkMeuPerfil_Click(object sender, EventArgs e)
        {
            Global.CookieCriar(Global.CK_IDPERFIL, Perfis.BuscarMeuIDPERFIL(this.Request).ToString(), this.Request, this.Response);
            Global.CookieCriar(Global.CK_PAGINAANTERIOR, "/Default.aspx", this.Request, this.Response);

            Response.Redirect("/Views/Perfis/Perfis_Edita.aspx");
        }
Ejemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Perfis perfis = db.Perfis.Find(id);

            db.Perfis.Remove(perfis);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        private void CompletarCamposPerfil(Perfis perfil)
        {
            textPerfil.Text          = perfil.Nome;
            textDescricaoPerfil.Text = perfil.Descricao;

            toolStripButton1.Enabled       = false;
            salvarToolStripButton1.Enabled = true;
        }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "PerfilID,Descricao")] Perfis perfis)
 {
     if (ModelState.IsValid)
     {
         db.Entry(perfis).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(perfis));
 }
Ejemplo n.º 9
0
 public bool Administrador()
 {
     if (Perfis == null || Perfis.Count() == 0)
     {
         return(false);
     }
     return
         (Perfis.Where(x => x.Descricao.Equals("administrador", StringComparison.InvariantCultureIgnoreCase))
          .Count() > 0);
 }
Ejemplo n.º 10
0
        public virtual void AdicionarPerfil(Perfil perfil)
        {
            if (Perfis.All(x => x.ID != perfil.ID))
            {
                var lista = new List <Perfil>();
                lista.AddRange(Perfis);
                lista.Add(perfil);

                Perfis = lista;
            }
        }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "PerfilID,Descricao")] Perfis perfis)
        {
            if (ModelState.IsValid)
            {
                db.Perfis.Add(perfis);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(perfis));
        }
        public frmLocalizarCliente(Perfis perfil)
        {
            InitializeComponent();

            switch (perfil)
            {
            case Perfis.Administrador:
                btnCriarPerfil.Visible = true;
                break;
            }
        }
Ejemplo n.º 13
0
 public void Post(Perfis perfil)
 {
     try
     {
         _perfilRepository.Adicionar(perfil);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 14
0
 public void Put(Guid id, Perfis perfil)
 {
     try
     {
         perfil.IdPerfil = id;
         _perfilRepository.Editar(perfil);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 15
0
 public void Adicionar(Perfis perfil)
 {
     try
     {
         _ctx.Perfis.Add(perfil);
         _ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 16
0
        public Perfis BuscarPorId(Guid id)
        {
            try
            {
                Perfis perfil = _ctx.Perfis.Find(id);

                return(perfil);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 17
0
        private void AbrirForm(int?tag, string perfil, string nome, Perfis tipoperfil = null)
        {
            this.Hide();

            MenuPrincipal menuPrincipal = new MenuPrincipal(tipoperfil);

            menuPrincipal.toolStripMenuItem2.Tag     = tag;
            menuPrincipal.toolStripStatusLabel3.Text = nome;
            menuPrincipal.toolStripStatusLabel4.Text = perfil;
            menuPrincipal.toolStripMenuItem2.Text    = nome;
            menuPrincipal.ShowDialog();
            this.Show();
        }
Ejemplo n.º 18
0
        private void Perfil(Perfis perfil)
        {
            switch (perfil.TipoPerfil)
            {
            case Library.Class.Enum.EnumPerfil.TipoPerfils.Chamado:
                this.toolStripChamado.Enabled            = true;
                this.toolStripChamadoDashBoard.Enabled   = true;
                this.toolStripUsuario.Enabled            = false;
                this.toolStripLogin.Enabled              = false;
                this.configurarToolStripMenuItem.Enabled = false;
                this.toolStripRelatorio.Enabled          = false;
                break;

            case Library.Class.Enum.EnumPerfil.TipoPerfils.Usuario:
                this.toolStripChamado.Enabled            = true;
                this.toolStripChamadoDashBoard.Enabled   = true;
                this.toolStripUsuario.Enabled            = true;
                this.toolStripLogin.Enabled              = false;
                this.configurarToolStripMenuItem.Enabled = false;
                this.toolStripRelatorio.Enabled          = false;
                break;

            case Library.Class.Enum.EnumPerfil.TipoPerfils.Login:
                this.toolStripChamado.Enabled            = true;
                this.toolStripChamadoDashBoard.Enabled   = true;
                this.toolStripUsuario.Enabled            = true;
                this.toolStripLogin.Enabled              = true;
                this.configurarToolStripMenuItem.Enabled = false;
                this.toolStripRelatorio.Enabled          = false;
                break;

            case Library.Class.Enum.EnumPerfil.TipoPerfils.Configuracao:
                this.toolStripChamado.Enabled            = true;
                this.toolStripChamadoDashBoard.Enabled   = true;
                this.toolStripUsuario.Enabled            = true;
                this.toolStripLogin.Enabled              = true;
                this.configurarToolStripMenuItem.Enabled = true;
                this.toolStripRelatorio.Enabled          = false;
                break;

            case Library.Class.Enum.EnumPerfil.TipoPerfils.Relatorio:
                this.toolStripChamado.Enabled            = true;
                this.toolStripChamadoDashBoard.Enabled   = true;
                this.toolStripUsuario.Enabled            = true;
                this.toolStripLogin.Enabled              = true;
                this.configurarToolStripMenuItem.Enabled = true;
                this.toolStripRelatorio.Enabled          = true;
                break;
            }
        }
Ejemplo n.º 19
0
        // GET: Perfis/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Perfis perfis = db.Perfis.Find(id);

            if (perfis == null)
            {
                return(HttpNotFound());
            }
            return(View(perfis));
        }
Ejemplo n.º 20
0
        public void Remover(Guid id)
        {
            try
            {
                Perfis perfil = BuscarPorId(id);

                if (perfil == null)
                {
                    throw new Exception("Perfil não encontrado");
                }

                _ctx.Perfis.Remove(perfil);
                _ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 21
0
        public MenuPrincipal(Perfis perfil)
        {
            InitializeComponent();
            _RepositoryChamado = new ControlChamado();

            Atencao form = new Atencao(this);

            this.LayoutMdi(MdiLayout.Cascade);
            form.WindowState = System.Windows.Forms.FormWindowState.Normal;
            form.MdiParent   = this;
            form.Location    = new Point(370, 180);
            form.Show();


            if (perfil != null)
            {
                Perfil(perfil);
            }
        }
Ejemplo n.º 22
0
        public void Editar(Perfis perfil)
        {
            try
            {
                Perfis perfilTemp = BuscarPorId(perfil.IdPerfil);

                if (perfilTemp == null)
                {
                    throw new Exception("Perfil não encontrado");
                }

                perfilTemp.Permissao = perfil.Permissao;
                _ctx.Perfis.Update(perfilTemp);
                _ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 23
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            var             token = actionContext.Request.Headers.Authorization?.Parameter;
            InformacaoToken info;

            if (EmissorTokenFactory.BuscaEmissorToken().ValidaToken(token, out info))
            {
                int?idAluno = null;
                if (info.TipoPerfil == PerfilPessoa.Aluno && !string.IsNullOrEmpty(PropriedadeRotaIdAluno))
                {
                    idAluno = Convert.ToInt32(actionContext.ControllerContext.RouteData.Values[PropriedadeRotaIdAluno]);
                }

                if ((Perfis == null || Perfis.Contains(info.TipoPerfil)) && (!idAluno.HasValue || idAluno.Value == info.IdPessoa))
                {
                    actionContext.Request.Properties.Add(Controlador.ChaveInformacaoToken, info);
                    return;
                }
            }
            actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
        }
Ejemplo n.º 24
0
        public BaseReturn CadastrarPerfil(string nome, string descricao, TipoPerfils tipoperfil)
        {
            var Dados = PesquisarPerfil()
                        .Where(y => y.Nome == nome).FirstOrDefault();

            if (Dados != null)
            {
                return(new BaseReturn("Perfil", Library.Class.Resources.Message.JA_EXISTE_UMA_X0_CHAMADA_X1.ToFormat("Nome", Dados.Nome.ToString()), true));
            }


            Perfis DadosPerfil = new Perfis(descricao, nome, tipoperfil);

            if (DadosPerfil.IsInvalid())
            {
                return(new BaseReturn(DadosPerfil.Notifications.FirstOrDefault().Property, DadosPerfil.Notifications.FirstOrDefault().Message, false));
            }

            _RepositoryPerfil.Add(DadosPerfil);

            return(new BaseReturn("Perfil", Library.Class.Resources.Message.OPERACAO_REALIZADA_COM_SUCESSO, true));
        }
Ejemplo n.º 25
0
        public virtual bool PossuiPermissao(Usuario usuario)
        {
            if (IsPaginaInicial())
            {
                return(true);
            }

            if (ConsiderarNacionalizacaoUf == true && !TodosPerfis && !usuario.UF.IsNacionalizado())
            {
                return(false);
            }

            if (!TodosPerfis)
            {
                if (!Perfis.Any(p => usuario.ListaPerfil.Select(x => x.Perfil.ID).Contains(p.ID)))
                {
                    return(false);
                }
            }

            if (!TodasUfs)
            {
                if (!Ufs.Select(x => x.ID).Contains(usuario.UF.ID))
                {
                    return(false);
                }
            }

            if (!TodosNiveisOcupacionais)
            {
                if (!NiveisOcupacionais.Select(x => x.ID).Contains(usuario.NivelOcupacional.ID))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 26
0
 private bool TemEssePerfil(Perfil perfil)
 {
     return(Perfis.Any(x => x == perfil));
 }
Ejemplo n.º 27
0
 public void AdicionarPerfil(Perfil perfil)
 {
     Perfis.Add(perfil);
 }
Ejemplo n.º 28
0
 public bool IsInRole(string perfil)
 {
     return(Perfis.Any(p => p.Contains(perfil)));
 }
Ejemplo n.º 29
0
 public bool TemEssePerfil(Perfil perfil)
 {
     return(Perfis.Any(x => x == perfil));
 }
Ejemplo n.º 30
0
 public virtual void RemoverPerfil(Enumeradores.Perfil perfil)
 {
     Perfis.Remove(perfil);
 }