Exemplo n.º 1
0
 public ActionResult Editar(hotel h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         List <categoria> categorias = db.categoria.ToList();
         ViewData["listaCategoria"] = categorias;
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             hotel hotel = db.hotel.Find(h.id);
             hotel.nombre             = h.nombre;
             hotel.telefono           = h.telefono;
             hotel.fecha_construccion = h.fecha_construccion;
             hotel.direccion          = h.direccion;
             hotel.categoria_id       = h.categoria_id;
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "El hotel fue actualizado."
             };
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar el hotel."
             };
             return(View());
         }
     }
 }
Exemplo n.º 2
0
 public ActionResult Agregar(categoria h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             db.categoria.Add(h);
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La categoria fue agregada."
             };
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la categoria."
             };
             return(View());
         }
     }
 }
Exemplo n.º 3
0
 public ActionResult Eliminar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             categoria categoria = db.categoria.Find(id);
             db.categoria.Remove(categoria);
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La categoria fue eliminada."
             };
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             ModelState.AddModelError("Error al eliminar el categoria.", e);
             return(View());
         }
     }
 }
Exemplo n.º 4
0
 public ActionResult Editar(categoria h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             categoria categoria = db.categoria.Find(h.id);
             categoria.nombre      = h.nombre;
             categoria.descripcion = h.descripcion;
             categoria.iva         = h.iva;
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La categoria fue actualizada."
             };
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la categoria."
             };
             return(View());
         }
     }
 }
Exemplo n.º 5
0
 public ActionResult Agregar(hotel h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         List <categoria> categorias = db.categoria.ToList();
         ViewData["listaCategoria"] = categorias;
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             db.hotel.Add(h);
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "El hotel fue agregado satisfactoriamente."
             };
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar el hotel."
             };
             return(View());
         }
     }
 }
Exemplo n.º 6
0
 public ActionResult Eliminar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             hotel hotel = db.hotel.Find(id);
             db.hotel.Remove(hotel);
             db.SaveChanges();
             return(RedirectToAction("Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al eliminar el hotel."
             };
             return(View());
         }
     }
 }
Exemplo n.º 7
0
 public ActionResult Editar(habitacion h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             habitacion hab = db.habitacion.Find(h.id);
             hab.codigo = h.codigo.ToUpper();
             hab.precio = h.precio;
             hab.clase  = h.clase;
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La habitación fue actualizada."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar la habitación."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
     }
 }
Exemplo n.º 8
0
        // GET: Hotel
        public ActionResult Inicio()
        {
            hotelesEntidad db      = new hotelesEntidad();
            List <hotel>   hoteles = hoteles = db.hotel.ToList();

            return(View(hoteles));
        }
Exemplo n.º 9
0
        public ActionResult Editar(int id)
        {
            using (hotelesEntidad db = new hotelesEntidad())
            {
                try
                {
                    string[]       lista  = Listado.getListado();
                    List <Listado> clases = new List <Listado>();

                    for (int i = 0; i < lista.Length; i++)
                    {
                        Listado item = new Listado();
                        item.id     = i;
                        item.nombre = lista[i];
                        clases.Add(item);
                    }
                    ViewData["listaClases"] = clases;
                    habitacion h = db.habitacion.Find(id);
                    return(View(h));
                }
                catch (Exception e)
                {
                    TempData["Mensaje"] = new Mensajes()
                    {
                        Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar esta habitación."
                    };
                    return(RedirectToAction("Inicio"));
                }
            }
        }
Exemplo n.º 10
0
 public ActionResult Eliminar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             habitacion h = db.habitacion.Find(id);
             db.habitacion.Remove(h);
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La categoria fue eliminada."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la categoria."
             };
             return(RedirectToAction("Inicio", "Hotel"));
         }
     }
 }
Exemplo n.º 11
0
        // GET: Categoria
        public ActionResult Inicio()
        {
            hotelesEntidad   db         = new hotelesEntidad();
            List <categoria> categorias = db.categoria.ToList();

            return(View(categorias));
        }
Exemplo n.º 12
0
 public ActionResult Agregar()
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         List <categoria> categorias = db.categoria.ToList();
         ViewData["listaCategoria"] = categorias;
         return(View());
     }
 }
Exemplo n.º 13
0
 public ActionResult Editar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         try
         {
             categoria h = db.categoria.Find(id);
             return(View(h));
         }
         catch (Exception e)
         {
             ModelState.AddModelError("Este categoria no existe.", e);
             return(RedirectToAction("Inicio"));
         }
     }
 }
Exemplo n.º 14
0
 public ActionResult Ver(int id)
 {
     try
     {
         hotelesEntidad db    = new hotelesEntidad();
         hotel          hotel = db.hotel.Find(id);
         ViewData["categoria"] = hotel.categoria.nombre;
         ViewData["id"]        = hotel.id;
         return(View(hotel));
     }
     catch (Exception e)
     {
         TempData["Mensaje"] = new Mensajes()
         {
             Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al ver el hotel."
         };
         return(View());
     }
 }
Exemplo n.º 15
0
        public ActionResult codigoExistente(string codigo, int id)
        {
            habitacion hab = null;

            using (hotelesEntidad db = new hotelesEntidad())
            {
                try {
                    hab = (from c in db.habitacion where c.codigo == codigo select c).First();
                }catch (Exception e) { }
            }
            if (hab.codigo == codigo && id != hab.id)
            {
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
Exemplo n.º 16
0
 public ActionResult Inicio(reserva r)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             int contador = db.reserva.Where(c => c.fechaInicio >= r.fechaInicio)
                            .Where(c => c.fechaTermino <= r.fechaTermino)
                            .Where(c => c.habitacion_id == r.habitacion_id).Count();
             if (contador == 0)
             {
                 db.reserva.Add(r);
                 db.SaveChanges();
                 TempData["Mensaje"] = new Mensajes()
                 {
                     Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La reserva fue creada."
                 };
             }
             else
             {
                 TempData["Mensaje"] = new Mensajes()
                 {
                     Clase = "alert-danger", Titulo = "Error!", Mensaje = "Existen clientes en este horario, seleccionar otro."
                 }
             };
             return(RedirectToAction("Inicio", "Inicio"));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la reserva."
             };
             return(RedirectToAction("Inicio", "Inicio"));
         }
     }
 }
Exemplo n.º 17
0
 public ActionResult Editar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         List <categoria> categorias = db.categoria.ToList();
         ViewData["listaCategoria"] = categorias;
         try
         {
             hotel h = db.hotel.Find(id);
             return(View(h));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar el hotel."
             };
             return(RedirectToAction("Inicio"));
         }
     }
 }
Exemplo n.º 18
0
 public ActionResult obtenerDetalle(string id, string fecha1 = null, string fecha2 = null)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (String.IsNullOrEmpty(id))
         {
             return(null);
         }
         int     cod     = 0;
         bool    isValid = Int32.TryParse(id, out cod);
         var     s       = db.habitacion.Find(cod);
         codigos co      = new codigos();
         co.codigo = s.codigo;
         co.precio = s.precio;
         co.hotel  = s.hotel.nombre;
         co.clase  = Listado.getLista(s.clase);
         co.iva    = s.hotel.categoria.iva;
         DateTime f1 = new DateTime();
         DateTime f2 = new DateTime();
         try
         {
             f1 = Convertir.aTimeStamp(Convert.ToInt64(fecha1));
             f2 = Convertir.aTimeStamp(Convert.ToInt64(fecha2));
         }
         catch (Exception e) {
             co.total = (co.precio * co.iva) / 100 + co.precio;
             return(Json(co, JsonRequestBehavior.AllowGet));
         }
         TimeSpan ts    = new TimeSpan();
         TimeSpan hora2 = new TimeSpan(12, 0, 0);
         ts = f2.Subtract(f1);
         //ts2 = a2.Subtract(a1);
         co.tiempoExtra  = ts.Days + ((ts.Days == 1) ? " Día":" Dias");
         co.tiempoExtra += " con " + ts.Hours + ((ts.Hours == 1) ? " Hora" : " Horas");
         co.total        = (((ts.Days == 0) ? co.precio * 1 : co.precio * ts.Days) * co.iva) / 100 + co.precio;
         return(Json(co, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 19
0
        public ActionResult obtenerHabitaciones(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                return(null);
            }
            hotelesEntidad db           = new hotelesEntidad();
            int            cod          = 0;
            bool           isValid      = Int32.TryParse(id, out cod);
            var            habitaciones = from habitacion in db.habitacion
                                          where habitacion.hotel_id == cod
                                          select habitacion;
            var contenido = habitaciones.ToList <habitacion>();

            var result = (from s in contenido
                          select new
            {
                id = s.id,
                codigo = s.codigo,
                precio = s.precio
            }).ToList();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }