예제 #1
0
 public long AgregarRegistro(Registro data)
 {
     try
     {
         var result = -1;
         using (ctx_grupos ctx = new ctx_grupos())
         {
             Agency objAgency = new Agency
             {
                 documentType = data.documentType,
                 agencyName   = data.agencyName,
                 contactType  = data.contactType,
                 contactName  = data.contactName,
                 cityName     = data.cityName,
                 phoneNumber  = data.phoneNumber,
                 emailAddress = data.emailAddress,
                 userName     = data.emailAddress,
                 password     = data.password,
                 terminos     = data.terminos,
                 status       = false
             };
             ctx.Agency.Add(objAgency);
             ctx.SaveChanges();
             result = objAgency.agencyId;
         }
         return(result);
     }
     catch (GettingException ex)
     {
         StackTrace st    = new StackTrace(ex, true);
         StackFrame frame = st.GetFrame(0);
         throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
     }
 }
예제 #2
0
 public Agency Login(LoginRequest request)
 {
     try
     {
         Agency result = null;
         using (ctx_grupos ctx = new ctx_grupos())
         {
             var query = (from l in ctx.Agency
                          where l.userName == request.userName && l.password == request.password &&
                          l.status == true
                          select l).FirstOrDefault();
             if (query != null)
             {
                 result = query;
             }
         }
         return(result);
     }
     catch (GettingException ex)
     {
         StackTrace st    = new StackTrace(ex, true);
         StackFrame frame = st.GetFrame(0);
         throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
     }
 }
예제 #3
0
 public long CrearToken(EToken token)
 {
     try
     {
         long IdToken = -1;
         using (ctx_grupos ctx = new ctx_grupos())
         {
             Token nuevoToken = new Token
             {
                 NumberToken = token.NumberToken,
                 CreateDate  = token.CreateDate,
                 ExpireDate  = token.ExpireDate,
                 Email       = token.Email,
                 Status      = token.Status
             };
             ctx.Token.Add(nuevoToken);
             ctx.SaveChanges();
             IdToken = nuevoToken.IdToken;
         }
         return(IdToken);
     }
     catch (GettingException ex)
     {
         StackTrace st    = new StackTrace(ex, true);
         StackFrame frame = st.GetFrame(0);
         throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
     }
 }
예제 #4
0
 public List <Cities> ListaCiudades()
 {
     try
     {
         List <Cities> Listado = new List <Cities>();
         using (ctx_grupos ctx = new ctx_grupos())
         {
             var query = (from c in ctx.Cities where c.City_Status == true select c).ToList();
             if (query.Count > 0)
             {
                 Listado = query;
             }
         }
         return(Listado);
     }
     catch (GettingException ex)
     {
         StackTrace st    = new StackTrace(ex, true);
         StackFrame frame = st.GetFrame(0);
         throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
     }
 }
예제 #5
0
 public bool ValdidarEmail(string email)
 {
     try
     {
         bool result = false;
         using (ctx_grupos ctx = new ctx_grupos())
         {
             var query = (from u in ctx.Agency where u.emailAddress == email select u).FirstOrDefault();
             if (query != null)
             {
                 result = true;
             }
         }
         return(result);
     }
     catch (GettingException ex)
     {
         StackTrace st    = new StackTrace(ex, true);
         StackFrame frame = st.GetFrame(0);
         throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
     }
 }
예제 #6
0
        public long CambiarPassword(string correo, string token, string password)
        {
            try
            {
                long respuesta = -1;//1 => token no valido, 2=> password NO cambiada 3=> password Cambiada
                using (ctx_grupos ctx = new ctx_grupos())
                {
                    var query = (from a in ctx.Agency
                                 join t in ctx.Token on a.emailAddress equals t.Email
                                 where a.emailAddress == correo && t.NumberToken == token &&
                                 t.ExpireDate > DateTime.Now && t.Status == true
                                 select a).FirstOrDefault();
                    if (query != null)//token valido
                    {
                        query.password = password;
                        var tokenUsado = (from t in ctx.Token where t.NumberToken == token select t).FirstOrDefault();
                        if (tokenUsado != null)
                        {
                            tokenUsado.Status = false;
                        }
                        ctx.SaveChanges();
                        respuesta = 3;
                    }
                    else
                    {
                        respuesta = 1;
                    }
                }

                return(respuesta);
            }
            catch (GettingException)
            {
                return(2);
            }
        }