Ejemplo n.º 1
0
        public ActionResult BorrarClienteLoc(int id, short idOrden)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            string             _tkn      = Session["StringToken"].ToString();
            ClienteLocacionMod _ObjModel = CatalogoServicio.ObtenerModel(idOrden, id, _tkn);
            var respuesta = CatalogoServicio.EliminarClienteLocacion(_ObjModel, _tkn);

            TempData["RespuestaDTO"] = respuesta;
            return(RedirectToAction("AltaClienteDireccion"));
        }
Ejemplo n.º 2
0
        public ActionResult BorrarClienteLoc(int id, short idOrden)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            string             _tkn      = Session["StringToken"].ToString();
            ClienteLocacionMod _ObjModel = CatalogoServicio.ObtenerModel(idOrden, id, _tkn);
            var respuesta = CatalogoServicio.EliminarClienteLocacion(_ObjModel, _tkn);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("EditarLocaciones", "Clientes", new { id = _ObjModel.IdCliente }));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta;
                return(RedirectToAction("EditarLocaciones", "Clientes", new { id = _ObjModel.IdCliente }));
            }
        }
Ejemplo n.º 3
0
        public ActionResult GuardarLocaciones(ClienteLocacionMod _Obj)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            _tok = Session["StringToken"].ToString();

            var respuesta = CatalogoServicio.RegistraLocaciones(_Obj, _tok);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("EditarLocaciones", "Clientes", new { id = _Obj.IdCliente }));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta;
                return(RedirectToAction("EditarLocaciones", "Clientes", new { id = _Obj.IdCliente }));
            }
        }
Ejemplo n.º 4
0
        public ActionResult AltaClienteDireccion(PedidoModel _model, int?IdCliente, int?id, short?idOrden, string msj = null, string msjValid = null)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            string _tkn = Session["StringToken"].ToString();

            ViewBag.EsAdmin = TokenServicio.ObtenerEsAdministracionCentral(_tkn);
            if (ViewBag.EsAdmin)
            {
                ViewBag.Empresas = CatalogoServicio.Empresas(_tkn);
            }
            else
            {
                ViewBag.Empresas = CatalogoServicio.Empresas(_tkn).SingleOrDefault().NombreComercial;
            }

            PedidoModel modelP = new PedidoModel();

            ViewBag.ListaPaises  = CatalogoServicio.GetPaises(_tkn);
            ViewBag.ListaEstados = CatalogoServicio.GetEstados(_tkn);
            ClienteLocacionMod        clm  = new ClienteLocacionMod();
            List <ClienteLocacionMod> _lst = new List <ClienteLocacionMod>();

            if (IdCliente > 0)
            {
                if (_model.IdPedido > 0)
                {
                    ViewBag.Cliente = _model.NombreRfc;
                }
                else
                {
                    ViewBag.Cliente = TempData["Cliente"];
                }
                _model     = new PedidoModel();
                clm.IdPais = 0; clm.IdEstadoRep = 0;
                ClientesModel cm = new ClientesModel();
                _model.cliente            = cm;
                _model.cliente.IdCliente  = IdCliente.Value;
                _model.cliente.Locacion   = clm;
                modelP.cliente            = _model.cliente;
                modelP.cliente.Locaciones = CatalogoServicio.ObtenerLocaciones(IdCliente.Value, _tkn);
            }
            if (_model.cliente != null && IdCliente == null)
            {
                if (_model.cliente.IdEmpresa == 0)
                {
                    _model.cliente.IdEmpresa = TokenServicio.ObtenerIdEmpresa(_tkn);
                }
                var respuesta = CatalogoServicio.CrearCliente(_model.cliente, _tkn);
                if (respuesta.Exito)
                {
                    _model.cliente.IdCliente = respuesta.Id;
                    ViewBag.Cliente          = _model.cliente.Nombre + " " + _model.cliente.Apellido1 + " " + _model.cliente.Apellido2 + " " + _model.cliente.Rfc;
                    TempData["Cliente"]      = ViewBag.Cliente;
                }
                else
                {
                    TempData["RespuestaDTO"] = respuesta;
                    TempData["ErrorModel"]   = _model;
                    return(RedirectToAction("AltaCliente"));
                }
                clm.IdPais = 0; clm.IdEstadoRep = 0;
                _model.cliente.Locacion   = clm;
                _model.cliente.Locaciones = _lst;
                modelP.cliente            = _model.cliente;
            }
            if (id > 0)
            {
                if (msj == "modificacion")
                {
                    clm.IdPais = 0; clm.IdEstadoRep = 0;
                }
                else
                {
                    clm = CatalogoServicio.ObtenerModel(idOrden.Value, id.Value, _tkn); ViewBag.EsEdicion = true;
                }

                _model          = new PedidoModel();
                ViewBag.Cliente = TempData["Cliente"];
                _lst            = CatalogoServicio.ObtenerLocaciones(id.Value, _tkn);
                ClientesModel cm = new ClientesModel();
                _model.cliente            = cm;
                _model.cliente.Locacion   = clm;
                _model.cliente.Locaciones = _lst;
                _model.cliente.IdCliente  = id.Value;
                modelP.cliente            = _model.cliente;
            }


            if (TempData["RespuestaDTO"] != null)
            {
                if (!((RespuestaDTO)TempData["RespuestaDTO"]).Exito)
                {
                    ViewBag.MensajeError = Validar((RespuestaDTO)TempData["RespuestaDTO"]);
                }
                else
                {
                    ViewBag.Msj = ((RespuestaDTO)TempData["RespuestaDTO"]).Mensaje;
                }
            }

            if (msjValid != null)
            {
                ViewBag.MensajeError = msjValid;
            }
            return(View(modelP));
        }