Пример #1
0
        //public tblAnio RetrieveByAnioTexto(int anio)
        //{
        //    tblAnio Result = null;
        //    using (var r = new Repository<tblAnio>())
        //    {
        //        Result = r.Retrieve(p => p.anio == anio);
        //    }
        //    return Result;
        //}


        public tblAula RetrieveAulaByID(int id)
        {
            tblAula Result = null;

            using (var r = new Repository <tblAula>())
            {
                Result = r.Retrieve(p => p.idAula == id);
            }
            return(Result);
        }
Пример #2
0
        public JsonResult DeleteAula(int id)
        {
            var          aulBLL  = new AulaBLL();
            wmJsonResult objJson = new wmJsonResult();

            try
            {
                tblAula aula = aulBLL.RetrieveAulaByID(id);

                if (aula != null)
                {
                    var eveBLL = new EventoBLL();
                    List <tblEvento> listaEventos = eveBLL.RetrieveEventosAulaByID(id);

                    if (listaEventos.Count() >= 0)
                    {
                        //significa que tiene Eventos....
                    }

                    var            areaBLL    = new AreasBLL();
                    List <tblArea> listaAreas = areaBLL.RetrieveAreasAulaByID(id);

                    if (listaAreas.Count() >= 0)
                    {
                        //significa que tiene Areas....
                    }

                    bool banderita = aulBLL.Delete(id);

                    if (banderita == true)
                    {
                        objJson.bandera = true;
                        objJson.mensaje = "El Aula se eliminó correctamente";
                    }
                    else
                    {
                        objJson.bandera = false;
                        objJson.mensaje = "El Aula NO se eliminó correctamente";
                    }
                }
                else
                {
                    objJson.bandera = false;
                    objJson.mensaje = "El Aula no se encontró";
                }
            }
            catch
            {
                objJson.bandera = false;
                objJson.mensaje = "Ocurrio una excepcion al eliminar el Registro";
            }

            return(Json(objJson, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        // GET: Aulas/Edit/5
        public ActionResult Edit(int id)
        {
            var                AuBLL          = new AulaBLL();
            tblAula            objCol         = AuBLL.RetrieveAulaByID(id);
            var                ediBLL         = new EdificioBLL();
            List <tblEdificio> listaEdificios = ediBLL.RetrieveAll();

            ViewBag.idEdificio = new SelectList(listaEdificios, "idEdificio", "nombreEdificio", objCol.idEdificio);


            var ti_auBLL = new TipoAulaBLL();
            List <tblTipoAula> listaTipoAula = ti_auBLL.RetrieveAll();

            ViewBag.idTipoAula = new SelectList(listaTipoAula, "idTipoAula", "tipoAula", objCol.idTipoAula);


            return(View(objCol));
        }
Пример #4
0
        public bool Delete(int id)
        {
            bool    Result = false;
            tblAula obj    = RetrieveAulaByID(id);

            if (obj != null)
            {
                using (var r = new Repository <tblAula>())
                {
                    Result = r.Delete(obj);
                }
            }
            else
            {
                throw (new Exception("El aula seleccionada no se pudo eliminar."));
            }

            return(Result);
        }
Пример #5
0
        public ActionResult Create(tblAula Aulas)
        {
            var          AuBLL  = new AulaBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    AuBLL.Create(Aulas);
                    Result = RedirectToAction("Index");
                }
            }
            catch
            {
                return(View());
            }

            return(Result);
        }
Пример #6
0
        public bool Update(tblAula t)
        {
            bool Result = false;

            using (var r = new Repository <tblAula>())
            {
                tblAula ba = r.Retrieve(p => p.nombreAula == t.nombreAula &&
                                        p.idTipoAula == t.idTipoAula &&
                                        p.idAula == t.idAula && p.idEdificio != t.idEdificio);

                if (ba == null)
                {
                    Result = r.Update(t);
                }
                else
                {
                    throw (new Exception("No se pudo actualizar el aula seleccionada."));
                }
            }
            return(Result);
        }
Пример #7
0
        public tblAula Create(tblAula t)
        {
            tblAula Result = null;

            using (var r = new Repository <tblAula>())
            {
                tblAula ba = r.Retrieve(p => p.nombreAula == t.nombreAula &&
                                        p.idTipoAula == t.idTipoAula &&
                                        p.idEdificio == t.idEdificio &&
                                        p.idAula == t.idAula);

                if (ba == null)
                {
                    Result = r.Create(t);
                }
                else
                {
                    throw (new Exception("El aula ya existe."));
                }
            }
            return(Result);
        }