Пример #1
0
        public ActionResult EliminarArchivo(string archivo, string tipo, string caracteristica, int id)
        {
            try
            {
                _obrasManager.EliminarArchivo(archivo, tipo, caracteristica);
                TempData["FlashSuccess"] = MensajesResource.INFO_Obras_ActualizadoCorrectamente;
                return(RedirectToAction("Editar", "AdministrarComponentesMecanicos", new { @id = TempData["componente"] }));
            }
            catch (BusinessException businessEx)
            {
                TempData["FlashError"] = businessEx.Message;
                return(RedirectToAction("Editar", "AdministrarComponentesMecanicos", new { @id = TempData["componente"] }));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = MensajesResource.ERROR_General;
                return(RedirectToAction("Editar", "AdministrarComponentesMecanicos", new { @id = TempData["componente"] }));
            }
        }
Пример #2
0
        public ActionResult Eliminar(int id)
        {
            var perfil = _perfilManager.Find(id);

            if (perfil == null)
            {
                TempData["FlashError"] = CommonMensajesResource.ERROR_PerfilProveedor_PefilIdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _perfilManager.Eliminar(id);
                TempData["FlashSuccess"] = CommonMensajesResource.INFO_PerfilProveedor_EliminadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                TempData["FlashError"] = businessEx.Message;
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = CommonMensajesResource.ERROR_General;
                return(RedirectToAction("Index"));
            }
        }
Пример #3
0
        public ActionResult Editar(int id, ProtocoloViewModel model)
        {
            var protocolo = _protocolosManager.Find(id);
            var pdfUrl    = "";

            ViewBag.Obras =
                new SelectList(_obrasManager.FindObras(protocolo.obra_id), "id", "nombre", protocolo.obra_id);
            if (protocolo == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                HttpPostedFileBase pdf = Request.Files["Pdf"];

                if (pdf != null && pdf.ContentLength > 0)
                {
                    pdfUrl = CargarPdf(pdf);
                }
                else
                {
                    pdfUrl = protocolo.Url;
                }

                if (pdfUrl == null)
                {
                    pdfUrl = "null.jpg";
                }


                _protocolosManager.Actualizar(protocolo.obra_id,
                                              id,
                                              model.Nombre,
                                              pdfUrl.Trim());

                TempData["FlashSuccess"] = MensajesResource.INFO_Protocolos_ActualizadoCorrectamente;
                //return RedirectToAction("Editar", "AdministrarProtocolos", new { @id = id });
                return(RedirectToAction("Protocolos", "AdministrarProtocolos", new { @id = TempData["previo_id"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #4
0
        public ActionResult Crear(PefilProveedorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                _perfilManager
                .CrearProveedor(
                    model.Nombre,
                    model.RolesIds,
                    _commonManager.GetCuentaUsuarioAutenticado().Id);

                TempData["FlashSuccess"] = CommonMensajesResource.INFO_PerfilProveedor_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);
                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);
                return(View(model));
            }
        }
        public ActionResult Eliminar(int id)
        {
            try
            {
                _sugerenciasManager.Eliminar(id);
                // TempData["FlashSuccess"] = MensajesResource.INFO_MensajesInstitucionales_EliminadoCorrectamente;
                return(RedirectToAction("Index", "AdministrarSugerencias", new { @id = TempData["IDVENTA"] }));
            }
            catch (BusinessException businessEx)
            {
                TempData["FlashError"] = businessEx.Message;
                return(RedirectToAction("Index", "AdministrarSugerencias", new { @id = TempData["IDVENTA"] }));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = MensajesResource.ERROR_General;
                return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["IDVENTA"] }));
            }
        }
Пример #6
0
        public ActionResult Eliminar(int id)
        {
            try
            {
                _previosManager.Eliminar(id);
                TempData["FlashSuccess"] = MensajesResource.INFO_Previos_EliminadoCorrectamente;
                return(RedirectToAction("Editar", "AdministrarPrevios", new { @id = TempData["previo_id"] }));
            }
            catch (BusinessException businessEx)
            {
                TempData["FlashError"] = businessEx.Message;
                return(RedirectToAction("Editar", "AdministrarPrevios", new { @id = TempData["previo_id"] }));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = MensajesResource.ERROR_General;
                return(RedirectToAction("Editar", "AdministrarPrevios", new { @id = TempData["previo_id"] }));
            }
        }
        public ActionResult Crear(MensajeViewModel model, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                if (!String.IsNullOrEmpty(Request["pdf-mensaje"]))
                {
                    if (Request.Files.Count == 0)
                    {
                        ModelState.AddModelError(string.Empty, MensajesResource.ERROR_MensajesInstitucionales_PdfInvalido);
                        return(View(model));
                    }

                    var pdfUrl = CargarPdf(Request.Files[0]);

                    _mensajesInstitucionalesManager.CrearPdf(
                        model.Titulo,
                        pdfUrl,
                        DateTime.ParseExact(model.FechaPublicacion, "d/M/yyyy", CultureInfo.InvariantCulture),
                        DateTime.ParseExact(model.FechaCaducidad, "d/M/yyyy", CultureInfo.InvariantCulture),
                        MensajesInstitucionalesManager.GetEnviadoAByString(model.TipoProveedor));
                }
                else // Mensaje solo texto
                {
                    _mensajesInstitucionalesManager.CrearTexto(
                        model.Titulo,
                        model.Contenido,
                        DateTime.ParseExact(model.FechaPublicacion, "d/M/yyyy", CultureInfo.InvariantCulture),
                        DateTime.ParseExact(model.FechaCaducidad, "d/M/yyyy", CultureInfo.InvariantCulture),
                        MensajesInstitucionalesManager.GetEnviadoAByString(model.TipoProveedor));
                }

                TempData["FlashSuccess"] = MensajesResource.INFO_MensajesInstitucionales_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #8
0
        public ActionResult Crear(KitDapViewModel model, FormCollection collection)
        {
            var pdfUrl = "";

            ViewBag.Obras =
                new SelectList(_obrasManager.FindAll(), "id", "nombre", TempData["obra_id"]);
            TempData.Keep();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                HttpPostedFileBase pdf = Request.Files["Pdf"];

                if (pdf != null && pdf.ContentLength > 0)
                {
                    pdfUrl = CargarPdf(pdf);
                }
                else
                {
                    pdfUrl = "";
                }

                _kitdapsManager.Crear(Convert.ToInt32(TempData["previo_id"]), model.obra_id,
                                      model.Nombre,
                                      pdfUrl.Trim());
                TempData.Keep();

                TempData["FlashSuccess"] = MensajesResource.INFO_Kitdaps_CreadoCorrectamente;
                return(RedirectToAction("Kitdaps", "AdministrarKitDaps", new { @id = TempData["previo_id"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #9
0
        public ActionResult Editar(int id, DatoObraViewModel model)
        {
            var obra = _datoobrasManager.Find(id);

            if (obra == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _datoobrasManager.Actualizar(
                    id,
                    model.primercontacto,
                    model.contactotelefonicoobra,
                    model.correoelectronicoobra,
                    model.cargoobra,
                    model.nombreconstructora,
                    model.contactotelefonicoempresa,
                    model.correoelectronicoempresa,
                    model.cargoempresa,
                    model.direccionoficina,
                    model.ubicacionobra,
                    model.tipoobra,
                    model.numeroequipos,
                    model.tipoequipo,
                    model.vendidasclimb,
                    model.vendidasotros,
                    model.novendidas,
                    model.paralizadas);

                TempData["FlashSuccess"] = MensajesResource.INFO_GestionObras_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
        public ActionResult Crear(GestionObraViewModel model, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                _gestionobrasManager.Crear(
                    model.primercontacto,
                    model.contactotelefonicoobra,
                    model.correoelectronicoobra,
                    model.cargoobra,
                    model.nombreconstructora,
                    model.contactotelefonicoempresa,
                    model.correoelectronicoempresa,
                    model.cargoempresa,
                    model.direccionoficina,
                    model.ubicacionobra,
                    model.tipoobra,
                    model.numeroequipos,
                    model.tipoequipo,
                    model.vendidasclimb,
                    model.vendidasotros,
                    model.novendidas,
                    model.paralizadas);


                TempData["FlashSuccess"] = MensajesResource.INFO_GestionObras_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #11
0
        public ActionResult Crear(InformeViewModel model, FormCollection collection)
        {
            var pdfUrl = "";



            try
            {
                HttpPostedFileBase pdf = Request.Files["Pdf"];

                if (pdf != null && pdf.ContentLength > 0)
                {
                    pdfUrl = CargarPdf(pdf);
                }
                else
                {
                    pdfUrl = "";
                }
                _informesManager.Crear(Convert.ToInt32(TempData["venta_id"]),
                                       model.Nombre,
                                       pdfUrl.Trim(),
                                       model.Fecha);
                TempData.Keep();

                TempData["FlashSuccess"] = MensajesResource.INFO_Informes_CreadoCorrectamente;
                //return RedirectToAction("Index");
                return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] }));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] }));
            }
        }
Пример #12
0
        public ActionResult Eliminar(int id)
        {
            try
            {
                _fallasManager.Eliminar(id);
                TempData["FlashSuccess"] = MensajesResource.INFO_Fallas_EliminadoCorrectamente;
                if (TempData["OBRA_ID"] != null)
                {
                    return(RedirectToAction("Fallas", "AdministrarFallas", new { @id = TempData["OBRA_ID"] }));
                }
                else
                {
                    return(RedirectToAction("Index", "AdministrarFallas"));
                }
            }
            catch (BusinessException businessEx)
            {
                TempData["FlashError"] = businessEx.Message;
                if (TempData["OBRA_ID"] != null)
                {
                    return(RedirectToAction("Fallas", "AdministrarFallas", new { @id = TempData["OBRA_ID"] }));
                }
                else
                {
                    return(RedirectToAction("Index", "AdministrarFallas"));
                }
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = MensajesResource.ERROR_General;
                if (TempData["OBRA_ID"] != null)
                {
                    return(RedirectToAction("Fallas", "AdministrarFallas", new { @id = TempData["OBRA_ID"] }));
                }
                else
                {
                    return(RedirectToAction("Index", "AdministrarFallas"));
                }
            }
        }
        public ActionResult Editar(int id, ComponenteMecanicoSustitucionViewModel model)
        {
            var componentemecanico_sustitucion = _componentesmecanicos_sustitucionesManager.Find(id);

            if (componentemecanico_sustitucion == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _componentesmecanicos_sustitucionesManager.Actualizar(
                    id,
                    model.Tipo,
                    model.Caracteristicas,
                    model.Descripcion,
                    model.Marca,
                    model.Modelo,
                    model.Serial,
                    model.FechaFabricado,
                    model.Duracion,
                    model.Sustitucion,
                    model.Fotografia);

                // TempData["FlashSuccess"] = MensajesResource.INFO_UsuarioNazan_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #14
0
        public ActionResult CrearContacto(int id, FormCollection collection)
        {
            string email    = String.Empty;
            string telefono = String.Empty;
            string nombre   = Convert.ToString(collection["txtaddnombre"]);

            if (collection["txtaddemail"] != null)
            {
                email = Convert.ToString(collection["txtaddemail"]);
            }
            else
            {
                email = "";
            }

            if (collection["txtaddemail"] != null)
            {
                telefono = Convert.ToString(collection["txtaddtelefono"]);
            }
            else
            {
                telefono = "";
            }
            // string telefono = Convert.ToString(collection["txtaddtelefono"]);
            int obra_id = id;

            try
            {
                _obrasManager.CrearContacto(obra_id, nombre, email, telefono);

                TempData["FlashSuccess"] = MensajesResource.INFO_ObrasContacto_CreadoCorrectamente;
                return(RedirectToAction("Editar", "AdministrarObras", new { @id = id }));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);
                TempData["FlashError"] = MensajesResource.ERROR_ObrasContacto_CreadoIncorrectamente;
                ModelState.AddModelError(string.Empty, e.Message);
                return(View("Index"));
            }
        }
Пример #15
0
        public ActionResult Editar(string id, UsuarioNazanViewModel model)
        {
            ViewBag.Perfiles =
                new SelectList(_perfilManager.FindPerfilesNazan(), "Id", "Nombre");
            var usuario = _usuarioManager.Find(id);

            if (usuario == null)
            {
                TempData["FlashError"] = MensajesResource.ERROR_UsuarioNazan_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _usuarioManager.Actualizar(
                    id,
                    model.Nombre,
                    model.Apellido,
                    model.Email,
                    model.Telefono, null,
                    model.Password);

                _usuarioManager.ActualizarPerfil(id, model.Perfil);

                TempData["FlashSuccess"] = MensajesResource.INFO_UsuarioNazan_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #16
0
        public ActionResult Editar(int id, SugerenciaViewModel model)
        {
            var sugerencia = _sugerenciasManager.Find(id);

            if (sugerencia == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _sugerenciasManager.Actualizar(Convert.ToInt32(TempData["IDVENTA"]),
                                               id,
                                               model.Descripcion,
                                               model.Caracteristica,
                                               model.Numero,
                                               model.Fecha,
                                               model.AccionesTomadas,
                                               model.AccionesRecomendadas,
                                               model.GerenciaResponsable);

                TempData["FlashSuccess"] = MensajesResource.INFO_Sugerencias_ActualizadoCorrectamente;

                return(RedirectToAction("Index", "AdministrarSugerencias", new { @id = TempData["IDVENTA"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
        public ActionResult Crear(ComponenteMecanicoSustitucionViewModel model, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                _componentesmecanicos_sustitucionesManager.Crear(
                    model.Tipo,
                    model.Caracteristicas,
                    model.Descripcion,
                    model.Marca,
                    model.Modelo,
                    model.Serial,
                    model.FechaFabricado,
                    model.Duracion,
                    model.Sustitucion,
                    model.Fotografia);


                //TempData["FlashSuccess"] = MensajesResource.INFO_MensajesInstitucionales_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #18
0
        public ActionResult Crear(UsuarioProveedorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            CargarPerfiles();
            try
            {
                _usuarioManager
                .CrearProveedor(
                    model.UserName,
                    model.Nombre,
                    model.Apellido,
                    model.Email,
                    model.Telefono, //TODO
                    null,           //TODO
                    true,
                    model.Perfil,
                    model.Password,
                    _commonManager.GetCuentaUsuarioAutenticado().Id);


                TempData["FlashSuccess"] = CommonMensajesResource.INFO_UsuarioProveedor_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);
                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);
                return(View(model));
            }
        }
Пример #19
0
        public ActionResult Editar(int id, ComponenteMecanicoTipoViewModel model)
        {
            var componentemecanicotipo = _componentesmecanicostiposManager.Find(id);

            if (componentemecanicotipo == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _componentesmecanicostiposManager.Actualizar(
                    id,
                    model.Descripcion);

                // TempData["FlashSuccess"] = MensajesResource.INFO_UsuarioNazan_ActualizadoCorrectamente;
                // return RedirectToAction("Editar", "AdministrarComponentesMecanicosTipos", new { @id = id });
                return(RedirectToAction("Index", "AdministrarComponentesMecanicos"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #20
0
        public ActionResult Editar(int id, VentaViewModel model)
        {
            var venta = _ventasManager.Find(id);

            if (venta == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _ventasManager.Actualizar(
                    id,
                    model.Descripcion);

                TempData["FlashSuccess"] = MensajesResource.INFO_Ventas_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #21
0
        public ActionResult Editar(int id, PefilProveedorViewModel model)
        {
            var perfil = _perfilManager.Find(id);

            if (perfil == null)
            {
                TempData["FlashError"] = CommonMensajesResource.ERROR_PerfilProveedor_PefilIdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                _perfilManager.ActualizarProveedor(
                    id,
                    model.Nombre,
                    model.RolesIds);

                TempData["FlashSuccess"] = CommonMensajesResource.INFO_PerfilProveedor_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);
                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);
                return(View(model));
            }
        }
Пример #22
0
        public ActionResult Crear(SugerenciaViewModel model, FormCollection collection)
        {
            try
            {
                _sugerenciasManager.Crear(Convert.ToInt32(TempData["venta_id"]),
                                          model.Descripcion,
                                          model.Caracteristica,
                                          model.Numero,
                                          model.Fecha,
                                          model.AccionesTomadas,
                                          model.AccionesRecomendadas,
                                          model.GerenciaResponsable);


                TempData["FlashSuccess"] = MensajesResource.INFO_Sugerencias_CreadoCorrectamente;
                return(RedirectToAction("Index", "AdministrarSugerencias", new { @id = TempData["venta_id"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
        public ActionResult Editar(int id, PefilNazanViewModel model)
        {
            ActionResult actionResult;

            try
            {
                _perfilManager.ActualizarNazan(
                    id,
                    model.Nombre,
                    model.RolesIds);

                TempData["FlashSuccess"] = MensajesResource.INFO_PerfilNazan_ActualizadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                actionResult = View(model);
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                TempData["FlashError"] = MensajesResource.ERROR_General;
                return(RedirectToAction("Index"));
            }

            return(actionResult);
        }
Пример #24
0
        public ActionResult Crear(VentaViewModel model, FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                _ventasManager.Crear(
                    model.Descripcion);


                TempData["FlashSuccess"] = MensajesResource.INFO_Ventas_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #25
0
        public ActionResult Crear(PrevioViewModel model, FormCollection collection)
        {
            var Url = "";

            //var pdfUrlFechaInspeccion = "";
            //var pdfInformeEntregaFinal = "";
            //var pdfFechaDescargaResguardoFotografia = "";
            //var pdfFechaCulminacionMontajeFotografia = "";
            //var pdfFechaInspeccionVideo = "";


            //var pdfFechaFirmaContratoFotografia = "";
            //var pdfFechaPagoInicialFabricaFotografia = "";
            //var pdfFechaPagoInicialEquipoFotografia = "";
            //var pdfFechaConstruccionFotografia = "";
            //var pdfFechaSalidaFabricaFotografia = "";
            //var pdfFechaSalidaBuqueFotografia = "";
            //var pdfFechaLlegadaBuqueFotografia = "";
            //var pdfFechaPeriodoNacionalizacionFotografia = "";
            //var pdfFechaSalidaPuertoObraFotografia = "";

            //var pdfFechaInicioMontajeFotografia = "";
            //var pdfFechaEntregaSosoFotografia = "";
            //var pdfFechaCulminacionMontaje = "";
            //var pdfFechaConfiguracionFotografia = "";
            //var pdfFechaPeriodoPruebaFotografia = "";

            //var pdffechainspeccion = "";

            // if (!ModelState.IsValid) return View(model);

            try
            {
                HttpPostedFileBase FechaDescargaResguardoFotografia      = Request.Files["Pdf-FechaDescargaResguardoFotografia"];
                HttpPostedFileBase FechaFirmaContratoFotografia          = Request.Files["Pdf-FechaFirmaContratoFotografia"];
                HttpPostedFileBase FechaPagoInicialFabricaFotografia     = Request.Files["Pdf-FechaPagoInicialFabricaFotografia"];
                HttpPostedFileBase FechaPagoInicialEquipoFotografia      = Request.Files["Pdf-FechaPagoInicialEquipoFotografia"];
                HttpPostedFileBase FechaConstruccionFotografia           = Request.Files["Pdf-FechaConstruccionFotografia"];
                HttpPostedFileBase FechaSalidaFabricaFotografia          = Request.Files["Pdf-FechaSalidaFabricaFotografia"];
                HttpPostedFileBase FechaSalidaBuqueFotografia            = Request.Files["Pdf-FechaSalidaBuqueFotografia"];
                HttpPostedFileBase FechaLlegadaBuqueFotografia           = Request.Files["Pdf-FechaLlegadaBuqueFotografia"];
                HttpPostedFileBase FechaPeriodoNacionalizacionFotografia = Request.Files["Pdf-FechaPeriodoNacionalizacionFotografia"];
                HttpPostedFileBase FechaSalidaPuertoObraFotografia       = Request.Files["Pdf-FechaSalidaPuertoObraFotografia"];
                //HttpPostedFileBase ActivacionProtocoloGarantiaFabrica = Request.Files["Pdf-FechaDescargaResguardoFotografia"];
                HttpPostedFileBase FechaInicioMontajeFotografia = Request.Files["Pdf-FechaInicioMontajeFotografia"];
                HttpPostedFileBase FechaEntregaSosoFotografia   = Request.Files["Pdf-FechaEntregaSosoFotografia"];

                HttpPostedFileBase FechaConfiguracionFotografia      = Request.Files["Pdf-FechaConfiguracionFotografia"];
                HttpPostedFileBase FechaPeriodoPruebaFotografia      = Request.Files["Pdf-FechaPeriodoPruebaFotografia"];
                HttpPostedFileBase FechaCulminacionMontajeFotografia = Request.Files["Pdf-FechaCulminacionMontajeFotografia"];
                HttpPostedFileBase fechainspeccion      = Request.Files["Pdf"];
                HttpPostedFileBase FechaInspeccionVideo = Request.Files["Pdf-FechaInspeccionVideo"];
                HttpPostedFileBase InformeEntregaFinal  = Request.Files["Pdf-InformeEntregaFinal"];



                previos previo = _previosManager.Crear(model.FechaFirmaContrato,

                                                       model.FechaPagoInicialFabrica,

                                                       model.FechaPagoInicialEquipo,

                                                       model.FechaConstruccion,

                                                       model.FechaSalidaFabrica,

                                                       model.FechaSalidaBuque,

                                                       model.FechaLlegadaBuque,

                                                       model.FechaPeriodoNacionalizacion,

                                                       model.FechaSalidaPuertoObra,

                                                       model.FechaDescargaResguardo,
                                                       model.ActivacionProtocoloGarantiaFabrica,
                                                       model.FechaInicioMontaje,

                                                       model.FechaEntregaSoso,

                                                       model.FechaCulminacionMontaje,
                                                       model.FechaConfiguracion,

                                                       model.FechaPeriodoPrueba,

                                                       model.FechaInspeccion,
                                                       model.TecnicoInstalador,
                                                       model.CartaPresentacion, model.FechaIngresoProduccion, model.EstatusConstruccion, model.IngresoDepartamentoIngMan, model.SolicitudPagoInicialFabrica);



                HttpPostedFileBase file;

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();


                    if (d == "Pdf-FechaDescargaResguardoFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaDescargaResguardoFotografia");
                    }
                    if (d == "Pdf-FechaFirmaContratoFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaFirmaContratoFotografia");
                    }
                    if (d == "Pdf-FechaPagoInicialFabricaFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaPagoInicialFabricaFotografia");
                    }
                    if (d == "Pdf-FechaPagoInicialEquipoFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaPagoInicialEquipoFotografia");
                    }
                    if (d == "Pdf-FechaConstruccionFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaConstruccionFotografia");
                    }
                    if (d == "Pdf-FechaSalidaBuqueFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaSalidaBuqueFotografia");
                    }
                    if (d == "Pdf-FechaLlegadaBuqueFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaLlegadaBuqueFotografia");
                    }
                    if (d == "Pdf-FechaPeriodoNacionalizacionFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaPeriodoNacionalizacionFotografia");
                    }


                    if (d == "Pdf-FechaSalidaPuertoObraFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaSalidaPuertoObraFotografia");
                    }
                    if (d == "Pdf-FechaInicioMontajeFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaInicioMontajeFotografia");
                    }

                    if (d == "Pdf-FechaEntregaSosoFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaEntregaSosoFotografia");
                    }



                    if (d == "Pdf-FechaConfiguracionFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaConfiguracionFotografia");
                    }
                    if (d == "Pdf-FechaPeriodoPruebaFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaPeriodoPruebaFotografia");
                    }
                    if (d == "Pdf-FechaCulminacionMontajeFotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaCulminacionMontajeFotografia");
                    }
                    if (d == "Pdf-Pdf" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "Pdf");
                    }
                    if (d == "Pdf-FechaInspeccionVideo" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaInspeccionVideo");
                    }
                    if (d == "Pdf-InformeEntregaFinal" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "InformeEntregaFinal");
                    }


                    if (d == "Pdf-CartaPresentacion" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "CartaPresentacion");
                    }
                    if (d == "Pdf-FechaIngresoProduccion" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "FechaIngresoProduccion");
                    }
                    if (d == "Pdf-EstatusConstruccion" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "EstatusConstruccion");
                    }
                    if (d == "Pdf-IngresoDepartamentoIngMan" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "IngresoDepartamentoIngMan");
                    }
                    if (d == "Pdf-SolicitudPagoInicialFabrica" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(previo.Id, Url, "previos", "SolicitudPagoInicialFabrica");
                    }
                }


                //HttpPostedFileBase FechaDescargaResguardoFotografia = Request.Files["Pdf-FechaDescargaResguardoFotografia"];
                //HttpPostedFileBase FechaFirmaContratoFotografia = Request.Files["Pdf-FechaFirmaContratoFotografia"];

                //HttpPostedFileBase FechaPagoInicialFabricaFotografia = Request.Files["Pdf-FechaPagoInicialFabricaFotografia"];
                //HttpPostedFileBase FechaPagoInicialEquipoFotografia = Request.Files["Pdf-FechaPagoInicialEquipoFotografia"];
                //HttpPostedFileBase FechaConstruccionFotografia = Request.Files["Pdf-FechaConstruccionFotografia"];
                //HttpPostedFileBase FechaSalidaFabricaFotografia = Request.Files["Pdf-FechaSalidaFabricaFotografia"];
                //HttpPostedFileBase FechaSalidaBuqueFotografia = Request.Files["Pdf-FechaSalidaBuqueFotografia"];
                //HttpPostedFileBase FechaLlegadaBuqueFotografia = Request.Files["Pdf-FechaLlegadaBuqueFotografia"];
                //HttpPostedFileBase FechaPeriodoNacionalizacionFotografia = Request.Files["Pdf-FechaPeriodoNacionalizacionFotografia"];
                //HttpPostedFileBase FechaSalidaPuertoObraFotografia = Request.Files["Pdf-FechaSalidaPuertoObraFotografia"];
                ////HttpPostedFileBase ActivacionProtocoloGarantiaFabrica = Request.Files["Pdf-FechaDescargaResguardoFotografia"];
                //HttpPostedFileBase FechaInicioMontajeFotografia = Request.Files["Pdf-FechaInicioMontajeFotografia"];
                //HttpPostedFileBase FechaEntregaSosoFotografia = Request.Files["Pdf-FechaEntregaSosoFotografia"];


                //HttpPostedFileBase FechaConfiguracionFotografia = Request.Files["Pdf-FechaConfiguracionFotografia"];
                //HttpPostedFileBase FechaPeriodoPruebaFotografia = Request.Files["Pdf-FechaPeriodoPruebaFotografia"];
                //HttpPostedFileBase FechaCulminacionMontajeFotografia = Request.Files["Pdf-FechaCulminacionMontajeFotografia"];


                //HttpPostedFileBase fechainspeccion = Request.Files["Pdf"];
                //HttpPostedFileBase FechaInspeccionVideo = Request.Files["Pdf-FechaInspeccionVideo"];
                //HttpPostedFileBase InformeEntregaFinal = Request.Files["Pdf-InformeEntregaFinal"];

                TempData["FlashSuccess"] = MensajesResource.INFO_Previos_CreadoCorrectamente;
                return(RedirectToAction("Editar", "AdministrarPrevios", new { @id = TempData["previo_id"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #26
0
        public ActionResult Editar(int id, ObraViewModel model, FormCollection collection)
        {
            var obra     = _obrasManager.Find(id);
            var fotoUrl  = "";
            var fotoMapa = "";
            var Url      = "";

            var db = new EntitiesDap();

            ViewBag.contactos = _obrasManager.FindContactosObras(id);

            ViewBag.ArchivosFotografia = _obrasManager.FindFotografiasObras(id);

            ViewBag.ArchivosMapa = _obrasManager.FindMapasObras(id);

            if (obra == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                //HttpPostedFileBase file_foto = Request.Files["file-foto"];

                /*
                 * for (int i = 0; i < Request.Files.Count; i++)
                 * {
                 *  HttpPostedFileBase file_foto = Request.Files[i];
                 *
                 *  _obrasManager.AgregarArchivos();
                 *
                 * }
                 *
                 *
                 * HttpPostedFileBase file_mapa = Request.Files["file-mapa"];
                 *
                 * if (file_foto != null && file_foto.ContentLength > 0)
                 * {
                 *  fotoUrl = CargarPdf(file_foto);
                 * }
                 * else { fotoUrl = obra.foto; }
                 * if (file_mapa != null && file_mapa.ContentLength > 0)
                 * {
                 *  fotoMapa = CargarPdf(file_mapa);
                 * }
                 * else { fotoMapa = obra.mapa; }
                 */
                if (model.Nombre != null)
                {
                    _obrasManager.Actualizar(
                        id,
                        model.Nombre,
                        model.PersonaJuridica,
                        model.DireccionFacturacion,
                        model.DireccionOficina,
                        model.DireccionObra,
                        obra.TelefonoOficina,
                        obra.Contacto,
                        obra.Contacto2,
                        obra.Email,
                        obra.Email2, fotoUrl.Trim(), fotoMapa.Trim());
                }
                if (model.mapa != null)
                {
                    _obrasManager.AgregarArchivos(obra.Id, model.mapa, "obras", "mapa");
                }
                TempData["FlashSuccess"] = MensajesResource.INFO_Obras_ActualizadoCorrectamente;

                string nombre   = Convert.ToString(collection["txtaddnombre"]);
                string email    = Convert.ToString(collection["txtaddemail"]);
                string telefono = Convert.ToString(collection["txtaddtelefono"]);

                string editnombre   = Convert.ToString(collection["txteditnombre"]);
                string editemail    = Convert.ToString(collection["txteditemail"]);
                string edittelefono = Convert.ToString(collection["txtedittelefono"]);

                string deletenombre = Convert.ToString(collection["txtdeletenombre"]);

                int    obra_id               = id;
                string obracontacto_id       = Convert.ToString(collection["txteditid"]);;
                string obracontactodelete_id = Convert.ToString(collection["txtdeleteid"]);

                HttpPostedFileBase file;


                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();

                    if (d == "Pdf-Fotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(obra.Id, Url, "obras", "fotografia");
                    }
                }



                if (nombre != null)
                {
                    _obrasManager.CrearContacto(obra_id, nombre, email, telefono);
                }
                if (editnombre != null)
                {
                    _obrasManager.EditarContacto(Convert.ToInt32(obracontacto_id), editnombre, editemail, edittelefono);
                }
                if (deletenombre != null)
                {
                    _obrasManager.EliminarContacto(Convert.ToInt32(obracontactodelete_id));
                }

                return(RedirectToAction("Editar", "AdministrarObras", new { @id = id }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #27
0
        public ActionResult Crear(ObraViewModel model, FormCollection collection)
        {
            var Url      = "";
            var fotoMapa = "";

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                /*HttpPostedFileBase file_foto = Request.Files["file-foto"];
                 *
                 * HttpPostedFileBase file_mapa = Request.Files["file-mapa"];
                 *
                 * if (file_foto != null && file_foto.ContentLength > 0)
                 * {
                 *  fotoUrl = CargarPdf(file_foto);
                 * }
                 * else { fotoUrl = ""; }
                 * if (file_mapa != null && file_mapa.ContentLength > 0)
                 * {
                 *  fotoMapa = CargarPdf(file_mapa);
                 * }
                 * else { fotoMapa = ""; }
                 */
                obras obra = _obrasManager.Crear(
                    model.Nombre,
                    model.PersonaJuridica,
                    model.DireccionFacturacion,
                    model.DireccionOficina,
                    model.DireccionObra,
                    model.TelefonoOficina,
                    model.Contacto,
                    model.Contacto2,
                    model.Email,
                    model.Email2, "", "");


                _obrasManager.AgregarArchivos(obra.Id, model.mapa, "obras", "mapa");

                HttpPostedFileBase file;


                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();

                    if (d == "Pdf-Fotografia" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(obra.Id, Url, "obras", "fotografia");
                    }
                    if (d == "Pdf-Mapa" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(obra.Id, Url, "obras", "mapa");
                    }
                }

                TempData["FlashSuccess"] = MensajesResource.INFO_Obras_CreadoCorrectamente;
                return(RedirectToAction("Index"));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #28
0
        public ActionResult Editar(int id, ComponenteMecanicoViewModel model)
        {
            var Url    = "";
            var pdfUrl = "";

            var componentemecanico = _componentesmecanicosManager.Find(id);

            ViewBag.obra = _obrasManager.Find(Convert.ToInt32(TempData["obra_id"]));
            TempData.Keep();

            ViewBag.Sustitucion2 =
                new SelectList(new[] { new { ID = "SI", Name = "SI" }, new { ID = "NO", Name = "NO" }, }, "ID", "Name", componentemecanico.Sustitucion);

            if (componentemecanico == null)
            {
                //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto;
                return(RedirectToAction("Index"));
            }

            try
            {
                HttpPostedFileBase file;

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();

                    if (d == "Pdf" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(componentemecanico.Id, Url, "componentesmecanicos", "fotografia");
                    }
                }

                /*HttpPostedFileBase pdf = Request.Files["Pdf"];
                 *
                 * if (pdf != null && pdf.ContentLength > 0)
                 * {
                 *  pdfUrl = CargarPdf(pdf);
                 * }
                 * else { pdfUrl = componentemecanico.Fotografia; }
                 */

                _componentesmecanicosManager.Actualizar(
                    id,
                    model.Tipo,
                    model.Caracteristicas,
                    model.Descripcion,
                    model.Marca,
                    model.Modelo,
                    model.Serial,
                    model.FechaFabricado,
                    model.Duracion,
                    model.Sustitucion,
                    pdfUrl.Trim(), model.FechaSustitucion, model.FechaAlerta);

                // TempData["FlashSuccess"] = MensajesResource.INFO_UsuarioNazan_ActualizadoCorrectamente;
                if (TempData["equipo_id"] != null)
                {
                    return(RedirectToAction("ComponentesMecanicos", "AdministrarComponentesMecanicos", new { @id = TempData["equipo_id"] }));
                }
                else
                {
                    return(RedirectToAction("Sustituciones", "AdministrarComponentesMecanicos"));
                }
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                return(View(model));
            }
        }
Пример #29
0
        public ActionResult Crear(ComponenteMecanicoViewModel model, FormCollection collection)
        {
            var Url    = "";
            var pdfUrl = "";

            ViewBag.obra = _obrasManager.Find(Convert.ToInt32(TempData["obra"]));
            TempData.Keep();
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                /* HttpPostedFileBase pdf = Request.Files["Pdf"];
                 *
                 * if (pdf != null && pdf.ContentLength > 0)
                 * {
                 *   pdfUrl = CargarPdf(pdf);
                 * }
                 * else { pdfUrl = ""; }
                 */

                obras   obra   = _obrasManager.Find(Convert.ToInt32(TempData["obra"]));
                equipos equipo = _equiposManager.Find(Convert.ToInt32(TempData["equipo"]));

                componentesmecanicos cm = _componentesmecanicosManager.Crear(Convert.ToInt32(TempData["equipo"]),
                                                                             model.Tipo,
                                                                             model.Caracteristicas,
                                                                             model.Descripcion,
                                                                             model.Marca,
                                                                             model.Modelo,
                                                                             model.Serial,
                                                                             model.FechaFabricado,
                                                                             model.Duracion,
                                                                             model.Sustitucion,
                                                                             pdfUrl.Trim(), model.FechaSustitucion, model.FechaAlerta, obra.Nombre, equipo.Nombre);

                TempData.Keep();
                HttpPostedFileBase file;

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();

                    if (d == "Pdf" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(cm.Id, Url, "componentesmecanicos", "fotografia");
                    }
                }

                //TempData["FlashSuccess"] = MensajesResource.INFO_MensajesInstitucionales_CreadoCorrectamente;
                return(RedirectToAction("ComponentesMecanicos", "AdministrarComponentesMecanicos", new { @id = TempData["equipo"] }));
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                CommonManager.WriteAppLog(log, TipoMensaje.Error);

                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Пример #30
0
        protected void Application_Error(object sender, EventArgs e)
        {
            HttpContext httpContext       = ((MvcApplication)sender).Context;
            string      currentController = string.Empty;
            string      currentAction     = string.Empty;
            RouteData   currentRouteData  = RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext));

            if (currentRouteData != null)
            {
                if (currentRouteData.Values["controller"] != null && !string.IsNullOrEmpty(currentRouteData.Values["controller"].ToString()))
                {
                    currentController = currentRouteData.Values["controller"].ToString();
                }
                if (currentRouteData.Values["action"] != null && !string.IsNullOrEmpty(currentRouteData.Values["action"].ToString()))
                {
                    currentAction = currentRouteData.Values["action"].ToString();
                }
            }
            Exception ex        = Server.GetLastError();
            RouteData routeData = new RouteData();
            string    action    = string.Empty;

            if (ex is HttpException)
            {
                HttpException httpEx = ex as HttpException;
                switch (httpEx.GetHttpCode())
                {
                case 404:
                    action = "NotFound";
                    break;

                case 500:
                    action = "InternalServer";
                    break;

                case 403:
                case 401:
                    action = "NotAuthorize";
                    break;

                default:
                    action = "GenericError";
                    break;
                }
            }
            else
            {
                action = "GenericError";
                if (ex is BusinessException)
                {
                    CommonManager.WriteBusinessLog(CommonManager.BuildMessageLog(TipoMensaje.Error, currentController, currentAction, ex.ToString()), TipoMensaje.Error);
                }
                if (ex is Exception)
                {
                    CommonManager.WriteAppLog(CommonManager.BuildMessageLog(TipoMensaje.Error, currentController, currentAction, ex.ToString()), TipoMensaje.Error);
                }
            }
            httpContext.ClearError();
            httpContext.Response.Clear();
            httpContext.Response.StatusCode             = ex is HttpException ? ((HttpException)ex).GetHttpCode() : 0;
            httpContext.Response.TrySkipIisCustomErrors = true;
            routeData.Values["controller"] = "Error";
            routeData.Values["action"]     = action;
            routeData.Values["exception"]  = new HandleErrorInfo(ex, currentController, currentAction);
            IController        CommonManagerController = new Controllers.ErrorController();
            HttpContextWrapper wrapper = new HttpContextWrapper(httpContext);
            RequestContext     rc      = new RequestContext(wrapper, routeData);

            CommonManagerController.Execute(rc);
        }