Example #1
0
 public async Task Create(AccesoSistema model)
 {
     try
     {
         _db.dbSetAcceso.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
Example #2
0
        public List <Menu> Menu(int idPerfil, string key)
        {
            List <Menu> Listado;

            if (!Class.Seguridad.keyCorrecta(key))
            {
                Listado = new List <Menu>();
                return(Listado);
            }
            AccesoSistema Acc = new AccesoSistema();

            Listado = Acc.GetMenu(idPerfil);
            return(Listado);
        }
Example #3
0
        public UsuarioFirmado Acceso(Usuario user, string key)
        {
            UsuarioFirmado UserFirmado;

            if (!Class.Seguridad.keyCorrecta(key))
            {
                UserFirmado        = new UsuarioFirmado();
                UserFirmado.Activo = false;
                return(UserFirmado);
            }
            AccesoSistema Acc = new AccesoSistema();

            UserFirmado = Acc.IsAcceso(user);
            return(UserFirmado);
        }
Example #4
0
        public async Task Update(AccesoSistema model)
        {
            try
            {
                var _model = await _db.dbSetAcceso.FirstOrDefaultAsync(e => e.AccesoID == model.AccesoID);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        private void Volver_Click(object sender, EventArgs e)
        {
            var acceso = new AccesoSistema();

            this.Close();

            acceso.Show();
        }
Example #6
0
                                                           public async Task <IHttpActionResult> Update(AccesoSistema obj)
                                                           {
                                                               try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                     await _repository.Update(obj);

                                                                     return(Ok("Clave de usuario actualizada correctamente!")); }
                                                               catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                     return(InternalServerError(e)); }
                                                           }
Example #7
0
        private bool SignIn(string userName, string password, bool persistCookie = false)
        {
            FormsAuthentication.SignOut();
            bool success = false;
            Logear acceso = new Logear();

            var userNameOld = (userName.ToLower() == "test" ? "0" : userName);
            var passwordOld = (password == "Test2015k" ? "0" : password);

            var user = acceso.LoginAgenteWeb(int.Parse(userNameOld), passwordOld);

            if (user != null)
            {
                string rol = "";
                string name = user.Tables["catAgentes"].Rows[0]["cNombre"].ToString();
                if (user.Tables["catAgentes"].Rows[0]["nAgenteID"].ToString() == "0")
                {
                    rol = "A";
                    name = (userName.ToLower() == "test" ? "Usuario Test" : "Nancy Martinez");
                }

                VarProcAMC ProcAMC = new VarProcAMC();
                if (!ProcAMC.IniciarCarga())
                {
                    Session["UserObj"] = null;
                    ModelState.AddModelError("", "Error en inicio de la carga de variables");
                }
                else
                {
                    VarProcCentral proCentral = new VarProcCentral();
                    proCentral.IniciaDatos(VarProcAMC.strPeriodo);
                    AccesoSistema accesos = new AccesoSistema();
                    accesos.P_AccesosSistema("03", "E");

                    Session["UserObj"] = user;
                    Session["Periodo"] = "Periodo: " + VarProcAMC.strPeriodo;
                    Session["UserRol"] = rol;
                    if (password.Equals("agente" + userName))
                    {
                        Session["ChangePassword"] = 1;
                    }
                    else {
                        Session["ChangePassword"] = 0;
                    }

                    FormsAuthentication.SetAuthCookie(name, false);
                    success = true;
                }
            }

            return success;
        }