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); }
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"); } }
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()); } }
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(); } }
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); }
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); }
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); }
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); }
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(); } }
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); }
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); }
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); }
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); }
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); }
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); }
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(); } }
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); }
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); }
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); }
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); }