예제 #1
0
        public ActionResult AgregarItem([FromBody] DTOCatalogoItem auxDTO)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error", "Error en datos!"));
            }

            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            var Rnd  = new Random();
            var Repo = new CatalogoBLL();

            //auxDTO.Item.Rubro=Helper.GetListaRubros().First(x => x.Id == auxDTO.Item.RubroId);

            if (auxDTO.Foto != null)
            {
                var NombreArch = auxDTO.Foto.PathFoto;

                //String PathGuardar = Path.Combine(_env, "~/Fotos/") + NombreArch;
                //auxDTO.Foto.PathFoto = PathGuardar;
                auxDTO.Foto.PathFoto = NombreArch;
                auxDTO.Item.Foto     = auxDTO.Foto.PathFoto;
            }

            Repo.Agregar(auxDTO);

            return(View("Catalogo"));
        }
예제 #2
0
        // GET: Catalogo
        public ActionResult Index()
        {
            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            var ListaCatalogo = new CatalogoBLL().Listar();

            return(View("Catalogo", ListaCatalogo));
        }
예제 #3
0
        public ActionResult PrepararModificarItem(long ID)
        {
            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            ViewBag.ModoOper = "EDIT";
            var Repo   = new CatalogoBLL();
            var auxObj = Repo.ObtenerXID(ID);

            return(View("CatalogoItem", auxObj));
        }
예제 #4
0
        public ActionResult EliminarItem(long ID)
        {
            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            var Repo   = new CatalogoBLL();
            var auxObj = Repo.ObtenerXID(ID);

            Repo.Eliminar(auxObj);
            return(View("Catalogo"));
        }
예제 #5
0
        public ActionResult ModificarItem([FromBody] DTOCatalogoItem auxDTO)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error", "Error en datos!"));
            }

            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            var Repo = new CatalogoBLL();

            Repo.Modificar(auxDTO);

            //TODO:Reemplazar la foto existente en el servidor


            return(View("Catalogo"));
        }
예제 #6
0
        public String getList()
        {
            StringBuilder SB = new StringBuilder();

            if (this.IsAdminUserLoggedIn() == false)
            {
                throw new Exception("Access Denied");
            }

            var Repo       = new CatalogoBLL();
            var QryListado = from auxObj in Repo.Listar()
                             select new
            {
                auxObj.Nombre,
                auxObj.Habilitado,
                auxObj.Precio
            };

            var Ldo = QryListado.ToList();

            SB.Append("{ \"data\": [");

            for (int i = 0; i <= Ldo.Count() - 1; i++)
            {
                var item = Ldo[i];
                SB.Append("[\"" + item.Nombre + "\",\"" + item.Precio + "\",\"" + item.Habilitado + "\"]");

                if (i < Ldo.Count() - 1)
                {
                    SB.Append(",");
                }
            }

            SB.Append("]}");

            return(SB.ToString());
        }