Esempio n. 1
0
        public ActionResult DeleteConAjax(ClaseGym claseGym)
        {
            ClaseGym claseGymFind = _context.ClaseGym.Find(claseGym.IdClaseGym);

            _context.ClaseGym.Remove(claseGymFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Esempio n. 2
0
 public ActionResult CreateConAjax(ClaseGym claseGym)
 {
     if (ModelState.IsValid)
     {
         return(Json(new { result = true }));
     }
     return(Json(new { result = false }));
 }
Esempio n. 3
0
 public ActionResult EditConAjax(ClaseGym claseGym)
 {
     if (ModelState.IsValid)
     {
         _context.SaveChanges();
         return(Json(new { result = true }));
     }
     return(Json(new { result = false }));
 }
Esempio n. 4
0
 public ActionResult EditarCalendar(ClaseGym claseGym)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(claseGym).State = EntityState.Modified;
         _context.SaveChanges();
         return(Json(new { result = true }));
     }
     return(Json(new { result = false }));
 }
Esempio n. 5
0
        public ActionResult GuardarCalendar(ClaseGym claseGym)
        {
            if (ModelState.IsValid)
            {
                _context.ClaseGym.Add(claseGym);
                _context.SaveChanges();
                return(Json(new { status = true }));
            }

            return(Json(new { status = false }));
        }
Esempio n. 6
0
        public ActionResult BorrarCalendar(ClaseGym claseGym)
        {
            ClaseGym claseFind = _context.ClaseGym.Find(claseGym.IdClaseGym);

            if (claseFind != null)
            {
                _context.ClaseGym.Remove(claseFind);
                _context.SaveChanges();
                return(Json(new { status = true }));
            }
            return(Json(new { status = false }));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("IdClaseGym,IdSala,HoraInicio,HoraFinal,Fecha,Cupo,IdActividad,IdEmpleado,Estado")] ClaseGym claseGym)
        {
            if (id != claseGym.IdClaseGym)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(claseGym);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClaseGymExists(claseGym.IdClaseGym))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdActividad"] = new SelectList(_context.Actividad, "IdActividad", "Nombre", claseGym.IdActividad);
            ViewData["IdEmpleado"]  = _context.Empleado
                                      .Where(e => e.IdEmpleado == claseGym.IdEmpleado)
                                      .Select(e => new SelectListItem
            {
                Text  = e.Nombre + " " + e.Apellido1,
                Value = e.IdEmpleado.ToString()
            });
            //ViewData["IdEmpleado"] = new SelectList(_context.Empleado, "IdEmpleado", "Apellido1", claseGym.IdEmpleado);
            ViewData["IdSala"] = new SelectList(_context.Sala, "IdSala", "NombreSala", claseGym.IdSala);
            return(View(claseGym));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("IdClaseGym,IdSala,HoraInicio,HoraFinal,Fecha,Cupo,IdActividad,IdEmpleado,Estado")] ClaseGym claseGym)
        {
            if (ModelState.IsValid)
            {
                _context.Add(claseGym);
                await _context.SaveChangesAsync();

                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdActividad"] = new SelectList(_context.Actividad, "IdActividad", "Nombre", claseGym.IdActividad);
            ViewData["IdEmpleado"]  = _context.Empleado
                                      .Where(e => e.IdEmpleado == claseGym.IdEmpleado)
                                      .Select(e => new SelectListItem
            {
                Text  = e.Nombre + " " + e.Apellido1,
                Value = e.IdEmpleado.ToString()
            });
            //ViewData["IdEmpleado"] = new SelectList(_context.Empleado, "IdEmpleado", "Nombre"+"Apellido1", claseGym.IdEmpleado);
            ViewData["IdSala"] = new SelectList(_context.Sala, "IdSala", "NombreSala", claseGym.IdSala);
            return(View(claseGym));
        }