Beispiel #1
0
        public List <Roles> GetAllGerentes()
        {
            List <Gerente> P = new List <Gerente>();
            List <Roles>   G = new List <Roles>();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Gerente.ToList();
                }
                if (P.Count > 0)
                {
                    int n = 0;
                    foreach (Gerente I in P)
                    {
                        Roles R = new Roles();
                        R.Id     = I.Nombre;
                        R.Nombre = I.Nombre;
                        G.Insert(n, R);
                        n++;
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/GetAllGerentes*" + ""));
            }
            return(G);
        }
Beispiel #2
0
        public bool PutProducto(Producto m)
        {
            bool     resultado = false;
            Producto P         = new Producto();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Producto.Where(x => x.Codigo == m.Codigo).First();
                    if (P != null)
                    {
                        P.Nombre             = m.Nombre;
                        P.Descripcion        = m.Descripcion;
                        P.Precio             = m.Precio;
                        P.Impuesto           = m.Impuesto;
                        P.Moneda             = m.Moneda;
                        P.Estatus            = m.Estatus;
                        P.FechaActualizacion = m.FechaActualizacion;
                        Context.SaveChanges();
                        resultado = true;
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/PutProducto*" + ""));
            }
            return(resultado);
        }
 public void ClearComments()
 {
     using (var db = new SudokuContext())
     {
         db.Database.ExecuteSqlCommand("DELETE FROM Comments");
     }
 }
Beispiel #4
0
 public PayByPaypalController(IEngineDb _Metodo, IEngineProyect _Funcion, IEnginePaypal _Paypal, SudokuContext _Context)
 {
     this.Metodo  = _Metodo;
     this.Context = _Context;
     this.Funcion = _Funcion;
     this.Paypal  = _Paypal;
 }
 public ManagerController(IEngineDb _Metodo, IEngineProyect _Funcion, IEngineNotificacion _Notificacion, SudokuContext _Context)
 {
     this.Metodo       = _Metodo;
     this.Context      = _Context;
     this.Funcion      = _Funcion;
     this.Notificacion = _Notificacion;
 }
 public List <Rating> GetLastRatings()
 {
     using (var db = new SudokuContext())
     {
         return((from s in db.Ratings orderby s.TimeOfRating descending select s)
                .Take(3).ToList());
     }
 }
 public void RemoveRating(string name)
 {
     using (var db = new SudokuContext())
     {
         db.Remove(db.Ratings.Single(c => c.Name == name));
         db.SaveChanges();
     }
 }
 public List <Comment> GetLastComments()
 {
     using (var db = new SudokuContext())
     {
         return((from s in db.Comments orderby s.TimeOFComment descending select s)
                .Take(5).ToList());
     }
 }
Beispiel #9
0
 public List <Score> GetTopScores()
 {
     using (var db = new SudokuContext())
     {
         return((from s in db.Scores orderby s.Points descending select s)
                .Take(5).ToList());
     }
 }
 public int GetAverageRating()
 {
     using (var db = new SudokuContext())
     {
         List <int> ratings = (from s in db.Ratings select s.Mark).ToList();
         double     avg     = ratings.Count > 0 ? ratings.Average() : 0.0;
         return((int)Math.Round(avg));
     }
 }
 public Rating GetRating(string name)
 {
     using (var db = new SudokuContext())
     {
         return(db.Ratings.SingleOrDefault(r => r.Name == name));
         // return db.Ratings.First(r => r.Name == name);
         //return (from s in db.Ratings where s.Name == name select s).Take(1);
     }
 }
        public void RemoveComment(string name)
        {
            //var sql="DELETE FROM Comment WHERE Name= {}"

            using (var db = new SudokuContext())
            {
                db.Remove(db.Comments.First(c => c.Name == name));
                db.SaveChanges();
            }
        }
Beispiel #13
0
        public bool InsertarSucesoLog(SucesoLog model)
        {
            bool resultado = false;

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    Context.SucesoLog.Add(model);
                    Context.SaveChanges();
                    resultado = true;
                }
            }
            catch {}
            return(resultado);
        }
Beispiel #14
0
        public int ObtenerNumeroDePago()
        {
            int numero = 0;

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    numero = Context.PagoCliente.Max(x => x.Id) + 1;
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ObtenerNumeroDePago*" + ""));
            }
            return(numero);
        }
Beispiel #15
0
        public List <Producto> GetProductosParaVenta()
        {
            List <Producto> P = new List <Producto>();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Producto.ToList();
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/GetProductosParaVenta*" + ""));
            }
            return(P);
        }
Beispiel #16
0
        public Gerente GetLoginGerente(string password)
        {
            Gerente P = new Gerente();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Gerente.Where(x => x.Password == password).First();
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/GetLoginGerente*" + ""));
            }
            return(P);
        }
Beispiel #17
0
        public void AddScore(Score score)
        {
            if (score == null)
            {
                throw new ServiceException("Score must be not null!");
            }
            if (score.Name == null)
            {
                throw new ServiceException("Score contains null Name!");
            }

            using (var db = new SudokuContext())
            {
                db.Add(score);
                db.SaveChanges();
            }
        }
Beispiel #18
0
        public Gerente GetGerenteUserName(string nombreUsuario)
        {
            Gerente P = new Gerente();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Gerente.Where(x => x.NombreUsuario == nombreUsuario).First();
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/GetGerenteUserName*" + ""));
            }
            return(P);
        }
Beispiel #19
0
        public Producto GetProducto(string codigo)
        {
            Producto P = new Producto();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    P = Context.Producto.Where(x => x.Codigo == codigo).First();
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/GetProducto*" + ""));
            }
            return(P);
        }
Beispiel #20
0
        public List <Producto> ProductosParaVenta()
        {
            List <Producto> P = new List <Producto>();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    int id = Context.Producto.Where(u => u.Estatus == true).Max(u => u.Id);
                    P = Context.Producto.Where(x => x.Id == id).ToList();
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ProductosParaVenta*" + ""));
            }
            return(P);
        }
Beispiel #21
0
        public bool InsertarTransaccionPaypal(TransaccionPaypal model)
        {
            bool resultado = false;

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    Context.TransaccionPaypal.Add(model);
                    Context.SaveChanges();
                    resultado = true;
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/InsertarTransaccionPaypal*"));
            }
            return(resultado);
        }
Beispiel #22
0
        public bool InsertarResetPassword(ResetPassword model)
        {
            bool resultado = false;

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    Context.ResetPassword.Add(model);
                    Context.SaveChanges();
                    resultado = true;
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/InsertarResetPassword*" + model.Email));
            }
            return(resultado);
        }
Beispiel #23
0
        public bool InsertarNuevoGerente(Gerente model)
        {
            bool resultado = false;

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    Context.Gerente.Add(model);
                    Context.SaveChanges();
                    resultado = true;
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/InsertarNuevoGerente*" + ""));
            }
            return(resultado);
        }
Beispiel #24
0
        public void EstablecerCulturaCliente(string email)
        {
            Cliente C = new Cliente();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    C = Context.Cliente.Where(s => s.Email == email).FirstOrDefault();
                    if (C.Cultura != null)
                    {
                        Funcion.SetCultureInfo(C.Cultura);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/EstablecerCulturaCliente*" + email));
            }
        }
        public void AddRating(Rating rate)
        {
            if (rate == null)
            {
                throw new ServiceException("Rating must be not null!");
            }

            if (rate.Name == null)
            {
                throw new ServiceException("Rating contains null Name!");
            }

            if (rate.Mark > 5 || rate.Mark < 0)
            {
                throw new ServiceException("Rating must be from 0 to 5");
            }

            using (var db = new SudokuContext())
            {
                //db.Add(rate);
                //db.SaveChanges();


                var name = rate.Name;
                if (db.Ratings.Any(e => e.Name == name))
                {
                    //var currentRating = db.Ratings.First(e => e.Name == name);
                    //currentRating.Name = name;

                    db.Ratings.Attach(rate);
                    db.Entry(rate).State = EntityState.Modified;
                }
                else
                {
                    db.Ratings.Add(rate);
                    db.Entry(rate).State = EntityState.Added;
                }

                db.SaveChanges();
            }
        }
        public void AddComment(Comment comment)
        {
            if (comment == null)
            {
                throw new ServiceException("Comment must be not null!");
            }
            if (comment.Name == null)
            {
                throw new ServiceException("Comment contains null Name!");
            }
            if (comment.Message == null)
            {
                throw new ServiceException("Comment contains null Message!");
            }

            using (var db = new SudokuContext())
            {
                db.Add(comment);
                db.SaveChanges();
            }
        }
Beispiel #27
0
        public bool InsertarClienteTest(IEngineProyect Funcion, string email)
        {
            bool    resultado = false;
            Cliente model     = new Cliente();

            model = Funcion.ConstruirInsertarClienteTest(email);
            using (SudokuContext Context = new SudokuContext())
            {
                try
                {
                    Context.Cliente.Add(model);
                    Context.SaveChanges();
                    resultado = true;
                }
                catch (Exception ex)
                {
                    InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/InsertarClienteTest*" + email));
                }
            };
            return(resultado);
        }
Beispiel #28
0
        public string ObtenerPasswordCliente(string email)
        {
            Cliente C = new Cliente();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    C = Context.Cliente.Where(s => s.Email == email).FirstOrDefault();
                    if (C.Password != string.Empty || C.Password != null)
                    {
                        return(C.Password);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ObtenerPasswordCliente*" + email));
            }
            return(string.Empty);
        }
Beispiel #29
0
        public Guid ObtenerIdentidadGerente(string email)
        {
            Gerente C = new Gerente();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    C = Context.Gerente.Where(s => s.Email == email).FirstOrDefault();
                    if (C.Identidad != null)
                    {
                        return(C.Identidad);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ObtenerIdentidadGerente*" + email));
            }
            return(Guid.Empty);
        }
Beispiel #30
0
        public string ObtenerCodigoRestablecerPassword(string email)
        {
            ResetPassword C = new ResetPassword();

            try
            {
                using (SudokuContext Context = new SudokuContext())
                {
                    C = Context.ResetPassword.Where(x => x.Email == email && x.Estatus == false).OrderByDescending(x => x.Id).Take(1).FirstOrDefault();
                    if (C != null)
                    {
                        return(C.Codigo);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertarSucesoLog(Funcion.ConstruirSucesoLog(ex.ToString().Substring(0, 300) + "*EngineDb/ObtenerCodigoRestablecerPassword*" + email));
            }
            return(string.Empty);
        }