Example #1
0
        // GET: HorasClase/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HORA_CLASE hORA_CLASE = db.HORA_CLASE.Find(id);

            if (hORA_CLASE == null)
            {
                return(HttpNotFound());
            }
            return(View(hORA_CLASE));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "ID_HORA_CLASE,HORA_INICIO,HORA_FIN")] HORA_CLASE hORA_CLASE)
        {
            if (ModelState.IsValid)
            {
                try {
                    HORA_CLASE hcAux = db.HORA_CLASE.FirstOrDefault(hc => hc.HORA_INICIO == hORA_CLASE.HORA_INICIO && hc.HORA_FIN == hORA_CLASE.HORA_FIN);

                    if (hcAux != null)
                    {
                        ModelState.AddModelError("", "La hora clase ya existe en base de datos");
                    }
                    else
                    {
                        hcAux = db.HORA_CLASE.FirstOrDefault(hc => hc.HORA_INICIO <hORA_CLASE.HORA_INICIO && hc.HORA_FIN> hORA_CLASE.HORA_INICIO);
                        if (hcAux != null)
                        {
                            ModelState.AddModelError("HORA_INICIO", "La hora de inicio no puede estar entre una hora clase ya registrada");
                        }
                        else
                        {
                            hcAux = db.HORA_CLASE.FirstOrDefault(hc => hc.HORA_INICIO <hORA_CLASE.HORA_FIN && hc.HORA_FIN> hORA_CLASE.HORA_FIN);
                            if (hcAux != null)
                            {
                                ModelState.AddModelError("HORA_FIN", "La hora de fin no puede estar entre una hora clase ya registrada");
                            }
                            else
                            {
                                db.HORA_CLASE.Add(hORA_CLASE);
                                db.SaveChanges();
                                return(RedirectToAction("Index"));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("NoConect", "Home"));
                }
            }

            return(View(hORA_CLASE));
        }
Example #3
0
 public ActionResult DeleteConfirmed(long id)
 {
     try {
         HORARIO hAux = db.HORARIO.FirstOrDefault(h => h.ID_HORA_CLASE == id);
         if (hAux == null)
         {
             HORA_CLASE hORA_CLASE = db.HORA_CLASE.Find(id);
             db.HORA_CLASE.Remove(hORA_CLASE);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Error", "Home"));
         }
     }
     catch (Exception ex)
     {
         return(RedirectToAction("NoConect", "Home"));
     }
 }