Beispiel #1
0
        public bool reservarMesa(string nombre, string apellido, string rut, string email, int telefono, string fecha, string hora, string cantidad)
        {
            try
            {
                string   windowsTime = fecha + " " + hora;
                DateTime date        = DateTime.Parse(windowsTime);;
                using (var var = new EntitiesRestaurante())
                {
                    CLIENTE c1i1 = var.CLIENTE.Where(n => n.RUT_CLIENTE == rut).FirstOrDefault();

                    if (c1i1 != null)
                    {
                        var.INSERTRESERVA(c1i1.ID_CLIENTE, 0, date);
                        var.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        var.INSERTCLIENTE(rut, nombre, apellido, email, telefono);
                        CLIENTE cli2 = var.CLIENTE.Where(n => n.RUT_CLIENTE == rut).FirstOrDefault();
                        var.INSERTRESERVA(cli2.ID_CLIENTE, 0, date);
                        var.SaveChanges();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                return(false);
            }
        }
        public void Agregar(int pIdProducto)
        {
            PEDIDO_PLATOS NuevoProducto = new PEDIDO_PLATOS();

            using (EntitiesRestaurante entities = new EntitiesRestaurante())
            {
                NuevoProducto.PLATO          = entities.PLATO.Where(n => n.ID_PLATO == pIdProducto).FirstOrDefault();
                NuevoProducto.PLATO_ID_PLATO = NuevoProducto.PLATO.ID_PLATO;
            }
            if (ListaProductos.Where(n => n.PLATO_ID_PLATO == NuevoProducto.PLATO_ID_PLATO).FirstOrDefault() != null)
            {
                foreach (PEDIDO_PLATOS item in ListaProductos)
                {
                    if (item.PLATO_ID_PLATO.Equals(NuevoProducto.PLATO_ID_PLATO))
                    {
                        item.CANTIDAD++;
                        return;
                    }
                }
            }
            else
            {
                NuevoProducto.CANTIDAD = 1;
                ListaProductos.Add(NuevoProducto);
            }
        }
        public void EliminarProductos(int pIdProducto)
        {
            PEDIDO_PLATOS eliminaritems = new PEDIDO_PLATOS();

            using (EntitiesRestaurante entities = new EntitiesRestaurante())
            {
                eliminaritems.PLATO          = entities.PLATO.Where(n => n.ID_PLATO == pIdProducto).FirstOrDefault();
                eliminaritems.PLATO_ID_PLATO = eliminaritems.PLATO.ID_PLATO;
            }
            ListaProductos.Remove(ListaProductos.Where(c => c.PLATO.ID_PLATO == eliminaritems.PLATO.ID_PLATO).First());
        }
        public override string[] GetRolesForUser(string username)
        {
            using (var context = new EntitiesRestaurante())
            {
                var result = (from ROL in context.ROL
                              join USUARIO in context.USUARIO on ROL.ID_ROL equals
                              USUARIO.ROL_ID_ROL
                              where USUARIO.NOMBRE_USUARIO == username
                              select ROL.NOMBRE).ToArray();

                return(result);
            }
        }
        public ActionResult Login(LoginViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                string password = Seguridad.Encriptar(model.Password);
                using (var var = new EntitiesRestaurante())
                {
                    var resultado = var.USUARIO.Where(n => n.EMAIL_USUARIO == model.Username.ToLower() && n.PASSWORD == password).FirstOrDefault();

                    if (resultado != null)
                    {
                        FormsAuthentication.SetAuthCookie(resultado.NOMBRE_USUARIO, false);
                        int id = resultado.ROL_ID_ROL;
                        if (id.Equals(1))
                        {
                            return(RedirectToAction("Index", "Usuario"));
                        }
                        else if (id.Equals(2))
                        {
                            return(RedirectToAction("Index", "Insumo"));
                        }
                        else if (id.Equals(3))
                        {
                            return(RedirectToAction("Index", "Pedido"));
                        }
                        else if (id.Equals(4))
                        {
                            return(RedirectToAction("Index", "Finanzas"));
                        }
                        else
                        {
                            this.ModelState.AddModelError(string.Empty, "Credenciales invalidas");
                            return(this.View(model));
                        }
                    }
                    else
                    {
                        this.ModelState.AddModelError(string.Empty, "Credenciales invalidas");
                        return(this.View(model));
                    }
                }
            }
            else
            {
                return(this.View(model));
            }
        }
Beispiel #6
0
 public MesaRepo()
 {
     this.context = new EntitiesRestaurante();
 }
Beispiel #7
0
 public MesaRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
Beispiel #8
0
 public FinanzasRepo()
 {
     this.context = new EntitiesRestaurante();
 }
Beispiel #9
0
 public FinanzasRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
 public InsumosRepo()
 {
     this.context = new EntitiesRestaurante();
 }
 public InsumosRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
 public ClienteRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
Beispiel #13
0
 public UsuarioRepo()
 {
     this.context = new EntitiesRestaurante();
 }
Beispiel #14
0
 public UsuarioRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
 public PedidoRepo(EntitiesRestaurante _context)
 {
     this.context = _context;
 }
 public PedidoRepo()
 {
     this.context = new EntitiesRestaurante();
 }
 public ClienteRepo()
 {
     this.context = new EntitiesRestaurante();
 }