Exemplo n.º 1
0
        public async Task <IActionResult> Create(string id)
        {
            NovedadesCreateViewModel novedadesCreateViewModel = new NovedadesCreateViewModel();

            if (!string.IsNullOrEmpty(id))
            {
                novedadesCreateViewModel.cedula = id;
                novedadesCreateViewModel.Placas = await _combosHelper.GetComboPlacasSN(id);

                novedadesCreateViewModel.MotivoTypes = await _combosHelper.GetComboTipoNovedades();

                novedadesCreateViewModel.SubMotivoTypes = await _combosHelper.GetComboSubMotivos();

                novedadesCreateViewModel.ViaIngresoTypes = await _combosHelper.GetComboViaIngreso();
            }
            else
            {
            }

            return(View(novedadesCreateViewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Crear(NovedadesCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                List <ArchivoNovedades> archivoNovedadesList = new List <ArchivoNovedades>();
                if (model.Files != null)
                {
                    foreach (IFormFile file in model.Files)
                    {
                        var path      = string.Empty;
                        var extension = string.Empty;

                        path = await _fileHelper.UploadFileAsync(file, "Novedades");

                        extension = Path.GetExtension(file.FileName);

                        var archivoNovedades = new ArchivoNovedades
                        {
                            //capacitacion = await _dataContext.capacitaciones.FindAsync(model.Id),
                            ArchivoPath = path,
                            user        = await _userHelper.GetUserAsync(this.User.Identity.Name),
                            Fecha       = DateTime.Now,
                            tamanio     = file.Length,
                            TipoArchivo = extension,
                            //Property = await _dataContext.Properties.FindAsync(model.Id)
                        };
                        archivoNovedadesList.Add(archivoNovedades);
                    }
                }

                var user = await _userHelper.GetUserAsync(this.User.Identity.Name);

                var novedad = new Novedad
                {
                    Cedula           = model.cedula,
                    EstadoSolucion   = "PENDIENTE",
                    Fecha            = DateTime.Now,
                    Observaciones    = model.Observaciones,
                    Placa            = model.PlacaId,
                    Motivo           = model.MotivoId,
                    SubMotivo        = model.SubMotivoId,
                    ViaIngreso       = model.ViaIngresoId,
                    archivoNovedades = archivoNovedadesList,
                    user             = user
                };



                _dataContext.novedades.Add(novedad);
                await _dataContext.SaveChangesAsync();

                await _logRepository.SaveLogs("Crear", "Crea Novedades id: " + novedad.Id.ToString(), "Novedades", User.Identity.Name);


                //enviar correo
                //var datos = await _datosRepository.GetDatosCliente(model.cedula);
                //var tipoAnalisis = await _dataContext.TiposAnalisis.FindAsync(model.TipoAnalisisId);

                //var emails = "*****@*****.**";
                var datos = await _userHelper.GetUserByCedulaAsync(model.cedula);

                var emails = user.Email + ',' + datos.Email;


                var idMotivo = await _datosRepository.GetTipoIncidenciaIdAsync(model.MotivoId);

                var idSubmotivo = await _datosRepository.GetSubMotivosIncidenciaIdAsync(model.SubMotivoId);

                var incidencia = new IncidenciaCreateViewModel
                {
                    Placa     = novedad.Placa,
                    submotivo = idSubmotivo.Id,
                    motivo    = idMotivo.Id.ToString(),
                    //usuario = user.UserName,
                    usuario          = "RENTING",
                    observacion      = novedad.Observaciones,
                    usuario_solucion = idSubmotivo.Usuario_asesor
                };
                var registroincidencia = await _datosRepository.IngresoIncidencia(incidencia);

                if (idSubmotivo.Correo_solucionadores != "")
                {
                    emails = emails + ',' + idSubmotivo.Correo_solucionadores;
                }

                //v2 email conductores
                var emailsdrivers = await _datosRepository.GetEmailConductorAsync(model.PlacaId);

                if (!string.IsNullOrEmpty(emailsdrivers))
                {
                    emails = emails + ',' + emailsdrivers;
                }
                ///
                var lognovedad = new LogNovedad
                {
                    Estado        = "PENDIENTE",
                    Fecha         = DateTime.Now,
                    Usuario       = user,
                    novedad       = novedad,
                    Observaciones = model.Observaciones,
                };
                _dataContext.logNovedades.Add(lognovedad);
                await _dataContext.SaveChangesAsync();


                //TODO: cambiar direccion de correo
                _mailHelper.SendMailAttachment(emails, "Plataforma Clientes",
                                               $"<html xmlns='http://www.w3.org/1999/xhtml'>" +
                                               $"<head>" +
                                               $"<meta http-equiv=" + "Content-Type" + " content=" + "text/html; charset = UTF-8" + " />" +
                                               $"<title>" +
                                               $"</title>" +
                                               $"</head>" +
                                               $"<body>" +
                                               //$"<h1>SoftCRP Nuevo Novedad</h1>" +
                                               $"<hr width=100% align='center' size=30 color='#002D73' style='margin:0px;padding:0px'>" +
                                               $"<hr width=100% align='center' size=5 color='#F2AE0B' style='margin:0px;padding:0px'>" +
                                               $"<br><br>" +
                                               $"<p>Estimado Cliente" +
                                               $"<p>Renting Pichincha comunica que se ha cargado en la plataforma de clientes una nueva Novedad perteneciente al vehículo:" +
                                               $"<table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' style='border-collapse:collapse; max-width:600px!important; width:100%; margin: auto'>" +
                                               $"<tr><td style='font-weight:bold'>Placa</td><td>{model.PlacaId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Motivo</td><td>{model.MotivoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>SubMotivo</td><td>{model.SubMotivoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Vía Ingreso</td><td>{model.ViaIngresoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Fecha</td><td>{novedad.Fecha}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>SLA</td><td>{idSubmotivo.Dias_sla} Días</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Estado</td><td>PENDIENTE</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Creador por</td><td>{user.FullName}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Observación</td><td>{model.Observaciones}</td></tr></table>" +
                                               $"<br><br>" +
                                               $"<p>Para poder revisar la información de su plataforma ingrese a su cuenta con su usuario y contraseña." +
                                               $"<div align='center'><a href='https://clientes.rentingpichincha.com'><img src='https://clientes.rentingpichincha.com/images/email1.png' align='center'></a></div>" +
                                               $"<br><br>" +
                                               $"<p>Es un placer estar en contacto.<br>" +
                                               $"<p>Saludos cordiales<br>" +
                                               $"<br><br>" +
                                               $"<p>Consorcio Pichincha S.A CONDELPI<br>" +
                                               $"<p>Av.González Suárez N32-346 y Coruña<br>" +
                                               $"<p><img src='https://clientes.rentingpichincha.com/images/call.png' width=30px>Call Center: 1-800 RENTING(736846)<br>" +
                                               $"<p><img src='https://clientes.rentingpichincha.com/images/email.png' width=25px>E-Mail: [email protected]<br>" +
                                               $"<p><img src='https://clientes.rentingpichincha.com/images/whatsapp.jpg' width=25px>WhatsApp: 0997652137" +
                                               $"<p>Quito-Ecuador" +
                                               $"<br><br>" +
                                               $"<img src='https://clientes.rentingpichincha.com/images/email2.png' width=200px>" +
                                               $"<hr width=100% align='center' size=30 color='#002D73' style='margin:0px;padding:0px'>" +
                                               $"<hr width=100% align='center' size=5 color='#F2AE0B' style='margin:0px;padding:0px'></body></html>"
                                               , model.Files);

                return(Ok(model));
            }
            //Alert("No se pudo agregar el cliente, revise los datos", Enum.Enum.NotificationType.error);
            //return View(model);
            return(BadRequest(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(NovedadesCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                List <ArchivoNovedades> archivoNovedadesList = new List <ArchivoNovedades>();

                foreach (IFormFile file in model.Files)
                {
                    var path      = string.Empty;
                    var extension = string.Empty;

                    path = await _fileHelper.UploadFileAsync(file, "Novedades");

                    extension = Path.GetExtension(file.FileName);

                    var archivoNovedades = new ArchivoNovedades
                    {
                        //capacitacion = await _dataContext.capacitaciones.FindAsync(model.Id),
                        ArchivoPath = path,
                        user        = await _userHelper.GetUserAsync(this.User.Identity.Name),
                        Fecha       = DateTime.Now,
                        tamanio     = file.Length,
                        TipoArchivo = extension,
                        //Property = await _dataContext.Properties.FindAsync(model.Id)
                    };
                    archivoNovedadesList.Add(archivoNovedades);
                }
                var user = await _userHelper.GetUserAsync(this.User.Identity.Name);

                var novedad = new Novedad
                {
                    Cedula           = model.cedula,
                    EstadoSolucion   = "PENDIENTE",
                    Fecha            = DateTime.Now,
                    Observaciones    = model.Observaciones,
                    Placa            = model.PlacaId,
                    Motivo           = model.MotivoId,
                    SubMotivo        = model.SubMotivoId,
                    ViaIngreso       = model.ViaIngresoId,
                    archivoNovedades = archivoNovedadesList,
                    user             = user
                };

                _dataContext.novedades.Add(novedad);
                await _dataContext.SaveChangesAsync();

                await _logRepository.SaveLogs("Crear", "Crea Novedades id: " + novedad.Id.ToString(), "Novedades", User.Identity.Name);

                var lognovedad = new LogNovedad
                {
                    Estado        = "PENDIENTE",
                    Fecha         = DateTime.Now,
                    Usuario       = user,
                    novedad       = novedad,
                    Observaciones = model.Observaciones,
                };
                _dataContext.logNovedades.Add(lognovedad);
                await _dataContext.SaveChangesAsync();

                //enviar correo
                //var datos = await _datosRepository.GetDatosCliente(model.cedula);
                //var tipoAnalisis = await _dataContext.TiposAnalisis.FindAsync(model.TipoAnalisisId);

                //var emails = "*****@*****.**";
                var datos = await _userHelper.GetUserByCedulaAsync(model.cedula);

                var emails = user.Email + ',' + datos.Email;

                //TODO: cambiar direccion de correo
                _mailHelper.SendMailAttachment(emails, "SoftCRP Nueva Novedad Creado",
                                               $"<html xmlns='http://www.w3.org/1999/xhtml'>" +
                                               $"<head>" +
                                               $"<meta http-equiv=" + "Content-Type" + " content=" + "text/html; charset = UTF-8" + " />" +
                                               $"<title>" +
                                               $"</title>" +
                                               $"</head>" +
                                               $"<body>" +
                                               $"<h1>SoftCRP Nuevo Novedad</h1>" +
                                               $"<table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' style='border-collapse:collapse; max-width:600px!important; width:100%; margin: auto'>" +
                                               $"<tr><td style='font-weight:bold'>Placa</td><td>{model.PlacaId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Motivo</td><td>{model.MotivoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>SubMotivo</td><td>{model.SubMotivoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Vía Ingreso</td><td>{model.ViaIngresoId}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Fecha</td><td>{novedad.Fecha}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Creador por</td><td>{user.FullName}</td></tr>" +
                                               $"<tr><td style='font-weight:bold'>Observación</td><td>{model.Observaciones}</td></tr></table></body></html>", model.Files);

                return(Ok(model));
            }
            //Alert("No se pudo agregar el cliente, revise los datos", Enum.Enum.NotificationType.error);
            //return View(model);
            return(BadRequest(model));
        }