public ActionResult Edit(Turnos_VM turno)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (dl.EditarTurno(turno))
                    {
                        //Mandar msj de confirmación de guardado
                        Success("Registro actualizado!", true);
                        return(RedirectToAction("Index"));
                    }

                    else
                    {
                        // return View(catalogos);
                    }
                }
                // TODO: Add insert logic here
                Danger("Error al actualizar registro", true);
                return(View(turno));
            }
            catch (Exception ex)
            {
                string msj = ex.ToString();
                Danger("Error al guardar registro: " + ex.ToString(), true);
                return(View(turno));
            }
        }
        public ActionResult Create(Turnos_VM turno)
        {
            try
            {
                //Docentes.listaCat= dc.ListarCatalogoId(52).ToList();
                if (ModelState.IsValid)
                {
                    if (dl.GuardarTurno(turno))
                    {
                        //Mandar msj de confirmación de guardado
                        Success("Registro Guardado", true);
                        return(RedirectToAction("Index"));
                    }

                    else
                    {
                        // return View(catalogos);
                    }
                }
                // TODO: Add insert logic here
                Danger("Error al guardar registro", true);
                return(View(turno));
            }
            catch (Exception ex)
            {
                string msj = ex.ToString();
                Danger("Error al guardar registro: " + ex.ToString(), true);
                return(View(turno));
            }
        }
        // GET: Turnos/Edit/5
        public ActionResult Edit(int id)
        {
            Turnos_VM Turno = new Turnos_VM();

            Turno = dl.ListarTurnoId(id);
            return(View(Turno));
        }
        // GET: Turnos/Details/5
        public ActionResult Details(int id)
        {
            Turnos_VM tur = new Turnos_VM();

            tur = dl.ListarTurnoId(id);
            return(View(tur));
        }
        public bool GuardarTurno(Turnos_VM turnos)
        {
            try
            {
                using (var contexto = new ControlAlumnosEntities())
                {
                    turnos tur = new turnos();

                    tur.nombre_turno  = turnos.nombre_turno;
                    tur.horario_turno = turnos.horario_turno;
                    tur.activo        = true;



                    contexto.turnos.Add(tur);
                    contexto.SaveChanges();


                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool EditarTurno(Turnos_VM TurnosId)
        {
            try
            {
                var Tur = new turnos {
                    idTurno = TurnosId.id
                };

                using (var context = new ControlAlumnosEntities())

                {
                    context.turnos.Attach(Tur);
                    Tur.idTurno       = TurnosId.id;
                    Tur.nombre_turno  = TurnosId.nombre_turno;
                    Tur.horario_turno = TurnosId.horario_turno;
                    Tur.activo        = TurnosId.activo;


                    context.Configuration.ValidateOnSaveEnabled = false;

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }
        public Turnos_VM ListarTurnoId(long id)
        {
            Turnos_VM lstTurno = new Turnos_VM();

            using (var contexto = new ControlAlumnosEntities())
            {
                lstTurno = contexto.turnos.Where(x => x.idTurno == id).Select(x => new Turnos_VM
                {
                    id            = x.idTurno,
                    nombre_turno  = x.nombre_turno,
                    horario_turno = x.horario_turno,
                    activo        = (bool)x.activo
                }).FirstOrDefault();

                return(lstTurno);
            }
        }
        // GET: Turnos/Create
        public ActionResult Create()
        {
            Turnos_VM turnos = new Turnos_VM();

            return(View(turnos));
        }