示例#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 tblServicio RetrieveServicioByID(int id)
        {
            tblServicio Result = null;

            using (var r = new Repository <tblServicio>())
            {
                Result = r.Retrieve(p => p.idservicios == id);
            }
            return(Result);
        }
示例#2
0
        // GET: Servicios/Edit/5
        public ActionResult Edit(int id)
        {
            var            serBLL     = new ServiciosBLL();
            tblServicio    objSer     = serBLL.RetrieveServicioByID(id);
            var            areaBLL    = new AreasBLL();
            List <tblArea> listaAreas = areaBLL.RetrieveAll();

            ViewBag.idArea = new SelectList(listaAreas, "idArea", "nombreArea", objSer.idArea);
            return(View(objSer));
        }
示例#3
0
        public bool Delete(int id)
        {
            bool        Result = false;
            tblServicio obj    = RetrieveServicioByID(id);

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

            return(Result);
        }
示例#4
0
        public ActionResult Edit(tblServicio servicio)
        {
            var          serBLL = new ServiciosBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    serBLL.Update(servicio);
                    Result = RedirectToAction("Index");
                }
            }
            catch
            {
                return(View());
            }
            return(Result);
        }
示例#5
0
        public bool Update(tblServicio t)
        {
            bool Result = false;

            using (var r = new Repository <tblServicio>())
            {
                tblServicio ba = r.Retrieve(p => p.idservicios == t.idservicios &&
                                            p.serviciosNombre == t.serviciosNombre &&
                                            p.idArea == t.idArea);

                if (ba == null)
                {
                    Result = r.Update(t);
                }
                else
                {
                    throw (new Exception("No se pudo actualizar el servicio seleccionado."));
                }
            }
            return(Result);
        }
示例#6
0
        public tblServicio Create(tblServicio t)
        {
            tblServicio Result = null;

            using (var r = new Repository <tblServicio>())
            {
                tblServicio ba = r.Retrieve(p => p.idservicios != t.idservicios &&
                                            p.serviciosNombre == t.serviciosNombre &&
                                            p.idArea == t.idArea);

                if (ba == null)
                {
                    Result = r.Create(t);
                }
                else
                {
                    throw (new Exception("El servicio ya existe."));
                }
            }
            return(Result);
        }
示例#7
0
        public JsonResult DeleteServicio(int id)
        {
            var          serBLL  = new ServiciosBLL();
            wmJsonResult objJson = new wmJsonResult();

            try
            {
                tblServicio servicio = serBLL.RetrieveServicioByID(id);

                if (servicio != null)
                {
                    bool banderita = serBLL.Delete(id);

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

            return(Json(objJson, JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public ActionResult Create(tblServicio servicio)
        {
            var          serBLL = new ServiciosBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    serBLL.Create(servicio);
                    Result = RedirectToAction("Index");
                }
                else
                {
                    Result = RedirectToAction("Index");
                }
            }
            catch
            {
                Result = RedirectToAction("Index");
            }
            return(Result);
        }