Exemplo n.º 1
0
        public int SetUsuario(USUARIOS usuario)
        {
            try
            {
                using (var context = new Model.BANKEntities())
                {
                    var newControl = new USUARIOS
                    {
                        nombre         = Common.Common.DesEncrypt(usuario.nombre),
                        apellido       = Common.Common.DesEncrypt(usuario.apellido),
                        email          = usuario.email,
                        telefono       = usuario.telefono,
                        id_rol         = usuario.id_rol,
                        identificacion = usuario.identificacion
                    };

                    context.USUARIOS.Add(newControl);
                    context.SaveChanges();
                    int id = (int)newControl.id;
                    return(id);
                }
            }
            catch (Exception)
            {
                return(0);

                throw;
            }
        }
Exemplo n.º 2
0
        public int SetAccount(CUENTAS cuenta)
        {
            try
            {
                using (var context = new Model.BANKEntities())
                {
                    var newControl = new CUENTAS
                    {
                        id_user  = cuenta.id_user,
                        cuenta   = cuenta.cuenta,
                        state_ac = cuenta.state_ac
                    };

                    context.CUENTAS.Add(newControl);
                    context.SaveChanges();
                    int id = (int)newControl.id;
                    return(id);
                }
            }
            catch (Exception)
            {
                return(0);

                throw;
            }
        }
Exemplo n.º 3
0
 public IEnumerable <CUENTAS> GetSateAccountbyId(string idAccount)
 {
     try
     {
         using (var context = new Model.BANKEntities())
         {
             return(context.CUENTAS.OrderBy(p => p.id).ToList().Where(p => p.cuenta == idAccount).Select(p => new CUENTAS()
             {
                 id = p.id, state_ac = p.state_ac
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 IEnumerable <USUARIOS> IService1.GetRolByIdUser(int idUser)
 {
     try
     {
         using (var context = new Model.BANKEntities())
         {
             return(context.USUARIOS.OrderBy(p => p.id).ToList().Where(p => p.id.Equals(idUser)).Select(p => new USUARIOS()
             {
                 id = p.id, nombre = p.nombre, apellido = p.apellido, email = p.email, id_rol = p.id_rol, identificacion = p.identificacion
             }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 IEnumerable <ROL> IService1.GetRolbyId(int id)
 {
     try
     {
         using (var context = new Model.BANKEntities())
         {
             var rol = new int[] { id };
             return(context.ROL.OrderBy(p => p.id).ToList().Where(p => rol.Contains(p.id)).Select(p => new ROL()
             {
                 id = p.id, rol1 = p.rol1
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 IEnumerable <USUARIO> IService1.GetUserByUserAndPass(string user, string pass)
 {
     try
     {
         using (var context = new Model.BANKEntities())
         {
             string passDes = Common.Common.DesEncrypt(pass);
             string userDes = Common.Common.DesEncrypt(user);
             return(context.USUARIO.OrderBy(p => p.id).ToList().Where(p => p.user_name.Equals(userDes) && p.password.Equals(passDes)).Select(p => new USUARIO()
             {
                 id = p.id, id_user = p.id_user, user_name = Common.Common.Encrypt(p.user_name), password = Common.Common.Encrypt(p.password)
             }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 7
0
 public IEnumerable <SALDO> GetBalance(string idAccount)
 {
     try
     {
         using (var context = new Model.BANKEntities())
         {
             var result = GetAccountbyId(idAccount);
             int id     = result.FirstOrDefault().id;
             return(context.SALDO.OrderBy(p => p.id).ToList().Where(p => p.id_cuenta == id).Select(p => new SALDO()
             {
                 id = p.id, id_cuenta = p.id_cuenta, saldo1 = p.saldo1, nuevo_saldo = p.nuevo_saldo
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
        public Result DelAccount(string idAccount)
        {
            try
            {
                using (var ctx = new Model.BANKEntities())
                {
                    codeResult = ctx.Database.ExecuteSqlCommand("UPDATE [CUENTAS] SET [state_account]= 0 WHERE [cuenta] = {0} ", idAccount);

                    return(new Result {
                        codigo = codeResult, Mensaje = "OK"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new Result {
                    codigo = 0, Mensaje = "Error " + ex.Message
                });

                throw;
            }
        }
Exemplo n.º 9
0
        public Result UptAccount(string idAccount, string numCuenta)
        {
            try
            {
                using (var ctx = new Model.BANKEntities())
                {
                    var result = GetAccountbyId(idAccount);
                    int id     = result.FirstOrDefault().id;
                    var state  = result.FirstOrDefault().state_ac;
                    if (state)
                    {
                        ctx.CUENTAS.Where(s => s.cuenta == idAccount).ToList().ForEach(s => {
                            s.cuenta = numCuenta;
                        });

                        //4. call SaveChanges
                        codeResult = ctx.SaveChanges();
                        return(new Result {
                            codigo = codeResult, Mensaje = "OK"
                        });
                    }
                    else
                    {
                        return(new Result {
                            codigo = 0, Mensaje = "Error cuenta bloqueada"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(new Result {
                    codigo = 0, Mensaje = ex.Message
                });
            }
        }