Exemple #1
0
        public async Task <IHttpActionResult> BuscarMotivoPQRS(string q, TipoPQRS t)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(q))
                {
                    return(Ok(new List <MotivoPQRS>()));
                }

                return(Ok(await db.MotivosPQRS
                          .Where(i => (i.Nombre.Contains(q)) && i.TipoPQRS == t && i.Activo == true)
                          .Select(i => new
                {
                    i.Id,
                    Nombre = i.Id + " - " + i.Nombre
                })
                          .Take(50)
                          .ToListAsync()
                          ));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #2
0
        public async Task <IHttpActionResult> MotivoPQRSList(TipoPQRS tipoPQRS)
        {
            var motivo = await db.MotivosPQRS.Where(m => m.TipoPQRS == tipoPQRS && m.Activo == true)
                         .Select(m => new { MotivoString = m.Id.ToString() + m.Nombre })
                         .ToListAsync();

            return(Ok(motivo));
        }
        public async Task <ActionResult> DetailsPanel(TipoPQRS TipoPQRS, int DataId, int RecordId)
        {
            var data = new PQRSTimeLineViewModel();

            if (TipoPQRS == TipoPQRS.Recruitment)
            {
                data.formato = await db.Recruitments
                               .Include(d => d.UsuarioCreacion)
                               .Include(d => d.Analista)
                               .Where(d => d.RecruitmentId == DataId && d.PQRSRecordId == RecordId)
                               .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.RecruitmentId,
                    FechaCreacion     = d.CreationDate,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = TipoPersona.Otro,
                    Persona           = "",
                    ClienteId         = "",
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Appointment,
                    Observacion       = d.Appointment,
                    Destinatarios     = d.Appointment,
                    NroTracking       = d.NroTracking
                })
                               .FirstOrDefaultAsync();

                data.formatoArchivos = new List <PQRSTimeLineViewModel.Comentarios.Archivos>();
                data.formatoItems    = new List <PQRSTimeLineViewModel.FormatoItems>();
                //data.formatoArchivos = await db.DevolucionArchivos
                //                             .Where(di => di.DevolucionId == DataId)
                //                             .Select(da => new PQRSTimeLineViewModel.Comentarios.Archivos { Item = da.Order, FileName = da.FileName })
                //                             .ToListAsync();
                //data.formatoItems = await db.DevolucionItems
                //                            .Include(di => di.MotivoPQRS)
                //                            .Include(di => di.Items)
                //                            .Where(di => di.DevolucionId == DataId && di.PQRSRecordId == RecordId)
                //                            .Select(di => new PQRSTimeLineViewModel.FormatoItems
                //                            {
                //                                Id = di.Id,
                //                                ItemId = di.ItemId,
                //                                Cantidad = di.Cantidad,
                //                                Precio = di.Precio,
                //                                NroFactura = di.NroFactura,
                //                                NroGuia = di.NroGuia,
                //                                MotivoPQRSId = di.MotivoPQRSId,
                //                                ComentarioAdicional = di.ComentarioAdicional,
                //                                Estado = di.Estado,
                //                                CantidadRecibida = di.CantidadRecibida,
                //                                CantidadSubida = di.CantidadSubida,
                //                                ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                //                                DocSoporte = di.DocSoporte,
                //                                MotivoPQRS = di.MotivoPQRS,
                //                                Items = di.Items
                //                            })
                //                            .ToListAsync();
            }

            //Lista de pasos.
            var PQRSRecords = await db.PQRSRecords
                              .Include(p => p.PQRSRecordUsuarios)
                              .Where(pr => pr.Id == RecordId).ToListAsync();

            data.PQRSRecords = PQRSRecords;



            //Lista de comentarios
            var PQRSRecordComentarios = await db.PQRSRecordComentarios
                                        .Include(pc => pc.Usuario)
                                        .Where(pc => pc.PQRSRecordId == RecordId).ToListAsync();

            List <PQRSTimeLineViewModel.Comentarios> Comentarios = new List <PQRSTimeLineViewModel.Comentarios>();

            foreach (var c in PQRSRecordComentarios)
            {
                PQRSTimeLineViewModel.Comentarios comentario = new PQRSTimeLineViewModel.Comentarios();
                comentario.PQRSRecordComentarios = c;
                comentario.PQRSRecordDocumentos  = await db.PQRSRecordDocumentos
                                                   .Include(pd => pd.TipoDocSoporte)
                                                   .Where(pd => pd.PQRSRecordComentarioId == c.Id).ToListAsync();

                comentario.PQRSRecordArchivos = await db.PQRSRecordArchivos
                                                .Where(pa => pa.PQRSRecordComentarioId == c.Id)
                                                .Select(pa => new PQRSTimeLineViewModel.Comentarios.Archivos {
                    Id = pa.PQRSRecordComentarioId, Item = pa.Item, FileName = pa.FileName
                }).ToListAsync();

                Comentarios.Add(comentario);
            }
            data.PQRSRecordComentarios = Comentarios;

            return(View(data));
        }
Exemple #4
0
        public async Task <ActionResult> AddAnswer(TipoPQRS TipoPQRS, int DataId, int RecordId, int Order, TipoComentario TipoComentario)
        {
            //validar si ya dio respuesta en ese paso



            var data = new AddCommentViewModel();

            data.TipoPQRS        = TipoPQRS;
            data.PQRSRecordId    = RecordId;
            data.PQRSRecordOrder = Order;
            data.TipoComentario  = TipoComentario;
            data.DataId          = DataId;
            var PQRSRecord = await db.PQRSRecords.Where(pr => pr.Id == RecordId && pr.Order == Order).FirstOrDefaultAsync();

            data.FlujoPQRSDescripcion = PQRSRecord.FlujoPQRSDescripcion;
            if (TipoPQRS == TipoPQRS.Devolucion)
            {
                var devolucion = await db.Devoluciones
                                 .Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (devolucion == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = $"Step {PQRSRecord.Order}: " + PQRSRecord.FlujoPQRSNombre + " Reason: " + PQRSRecord.MotivoPQRSNombre + " Subject: " + devolucion.Asunto;
                //data.AnalistaId = devolucion.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Garantia)
            {
                var garantia = await db.Garantias.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (garantia == null)
                {
                    return(HttpNotFound());
                }

                data.Asunto = $"Step {PQRSRecord.Order}:  " + PQRSRecord.FlujoPQRSNombre + " Reason: " + PQRSRecord.MotivoPQRSNombre + " Subject: " + garantia.Asunto;
                // data.AnalistaId = garantia.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Novedad)
            {
                var novedad = await db.Novedad.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (novedad == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = $"Step {PQRSRecord.Order}:  " + PQRSRecord.FlujoPQRSNombre + " Reason: " + PQRSRecord.MotivoPQRSNombre + " Subject: " + novedad.Asunto;
                // data.AnalistaId = novedad.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Recruitment)
            {
                var recruitment = await db.Recruitments.Where(d => d.RecruitmentId == DataId).FirstOrDefaultAsync();

                if (recruitment == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = $"Step {PQRSRecord.Order}:  " + PQRSRecord.FlujoPQRSNombre + " Reason: " + PQRSRecord.MotivoPQRSNombre + " Subject: " + recruitment.Appointment;
                // data.AnalistaId = novedad.AnalistaId;
            }
            else
            {
                return(HttpNotFound());
            }


            var Tareas = await db.PQRSRecordTareas.Where(pu => pu.PQRSRecordId == RecordId && pu.PQRSRecordOrder == Order).ToListAsync();

            data.Tareas = Tareas;
            //Condiciones
            int  Idx                 = Order + 1;
            bool flagCondiciones     = true;
            var  CondicionesViewList = new List <AddCommentViewModel.CondicionesView>();

            while (flagCondiciones)
            {
                var Condiciones = await db.PQRSRecordCondiciones
                                  .Include(pc => pc.PQRSRecord)
                                  .Where(pu => pu.PQRSRecordId == RecordId && pu.PQRSRecordOrder == Idx).ToListAsync();

                if (Condiciones.Count > 0)
                {
                    var CondicionesView = new AddCommentViewModel.CondicionesView();
                    CondicionesView.Condiciones = Condiciones;
                    CondicionesView.PQRSRecord  = Condiciones.FirstOrDefault().PQRSRecord;
                    CondicionesViewList.Add(CondicionesView);

                    Idx++;
                }
                else
                {
                    flagCondiciones = false;
                }
            }

            data.Condiciones = CondicionesViewList;


            ViewBag.TipoDocSoporteId = await db.TipoDocSoporte.ToListAsync();

            return(PartialView("_AddAnswer", data));
        }
Exemple #5
0
        public async Task <ActionResult> ReportTimeLine(string archivo, TipoPQRS TipoPQRS, int DataId, int RecordId)
        {
            LocalReport lr   = new LocalReport();
            string      path = Path.Combine(Server.MapPath("~/Reports"), "WCSS/PQRSTimeLine.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
                return(View("Index"));
            }
            //var Actividads = new List<dynamic>();
            dynamic formato;//= new List<PQRSTimeLineViewModel.Formato>();
            dynamic formatoItems;

            if (TipoPQRS == TipoPQRS.Devolucion)
            {
                formato = await db.Devoluciones
                          .Include(d => d.UsuarioCreacion)
                          .Include(d => d.Analista)
                          .Include(d => d.Cliente.ciudad.departamentos.paises)
                          .Include(d => d.Cliente.canal)
                          .Include(d => d.Cliente.usuario)
                          .Where(d => d.Id == DataId)
                          .Select(d => new
                {
                    TipoPQRS           = "Return",
                    Id                 = d.Id,
                    FechaCreacion      = d.FechaCreacion,
                    UsuarioIdCreacion  = d.UsuarioCreacion.UsuarioNombre,
                    Estado             = d.Estado,
                    Prioridad          = Prioridad.Baja,
                    TipoPersona        = TipoPersona.Otro,
                    Persona            = "",
                    ClienteId          = d.ClienteId,
                    ClienteRazonSocial = d.Cliente.ClienteRazonSocial,
                    Zona               = d.Cliente.ciudad.departamentos.paises.PaisDesc + "-" + d.Cliente.ciudad.departamentos.DepartamentoDesc + "-" + d.Cliente.ciudad.CiudadDesc,
                    Canal              = d.Cliente.canal.CanalDesc,
                    Vendedor           = d.Cliente.VendedorId + "-" + d.Cliente.usuario.UsuarioNombre,
                    AnalistaId         = d.Analista.UsuarioNombre,
                    Asunto             = d.Asunto,
                    Observacion        = d.Observacion,
                    Destinatarios      = d.Destinatarios,
                    NroTracking        = d.NroTracking
                })
                          .ToListAsync();

                formatoItems = await db.DevolucionItems
                               .Include(di => di.MotivoPQRS)
                               .Include(di => di.Items)
                               .Where(di => di.DevolucionId == DataId && di.PQRSRecordId == RecordId)
                               .Select(di => new
                {
                    Producto         = di.Items.Codigo + "-" + di.Items.Descripcion,
                    Cantidad         = di.Cantidad,
                    Precio           = di.Precio,
                    NroFactura       = di.NroFactura,
                    NroGuia          = di.NroGuia,
                    MotivoPQRSId     = di.MotivoPQRS.Nombre,
                    Estado           = di.Estado,
                    CantidadRecibida = di.CantidadRecibida,
                    CantidadSubida   = di.CantidadSubida,
                    DocSoporte       = di.DocSoporte,
                    MotivoPQRS       = di.MotivoPQRS,
                    Items            = di.Items
                })
                               .ToListAsync();
            }
            else if (TipoPQRS == TipoPQRS.Garantia)
            {
                formato = await db.Garantias
                          .Include(d => d.UsuarioCreacion)
                          .Include(d => d.Analista)
                          .Where(d => d.Id == DataId)
                          .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.Id,
                    FechaCreacion     = d.FechaCreacion,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = TipoPersona.Otro,
                    Persona           = "",
                    ClienteId         = d.ClienteId,
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Asunto,
                    Observacion       = d.Observacion,
                    Destinatarios     = d.Destinatarios,
                    NroTracking       = d.NroTracking
                }).ToListAsync();

                //data.formatoItems = await db.GarantiaItems
                //                            .Include(di => di.MotivoPQRS)
                //                            .Include(di => di.Items)
                //                            .Where(di => di.GarantiaId == DataId && di.PQRSRecordId == RecordId)
                //                            .Select(di => new PQRSTimeLineViewModel.FormatoItems
                //                            {
                //                                Id = di.Id,
                //                                ItemId = di.ItemId,
                //                                Cantidad = di.Cantidad,
                //                                Precio = di.Precio,
                //                                NroFactura = di.NroFactura,
                //                                NroGuia = di.NroGuia,
                //                                MotivoPQRSId = di.MotivoPQRSId,
                //                                ComentarioAdicional = di.ComentarioAdicional,
                //                                Estado = di.Estado,
                //                                CantidadRecibida = di.CantidadRecibida,
                //                                CantidadSubida = di.CantidadSubida,
                //                                ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                //                                DocSoporte = di.DocSoporte,
                //                                MotivoPQRS = di.MotivoPQRS,
                //                                Items = di.Items
                //                            })
                //                            .ToListAsync();
                formatoItems = new List <PQRSTimeLineViewModel.FormatoItems>();
            }
            else if (TipoPQRS == TipoPQRS.Novedad)
            {
                formato = await db.Novedad
                          .Include(d => d.UsuarioCreacion)
                          .Include(d => d.Analista)
                          .Where(d => d.Id == DataId)
                          .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.Id,
                    FechaCreacion     = d.FechaCreacion,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = d.TipoPersona,
                    Persona           = d.Persona,
                    ClienteId         = d.ClienteId,
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Asunto,
                    Observacion       = d.Observacion,
                    Destinatarios     = d.Destinatarios,
                    NroTracking       = d.NroTracking
                }).ToListAsync();

                //data.formatoItems = await db.NovedadItem
                //                            .Include(di => di.MotivoPQRS)
                //                            .Include(di => di.Items)
                //                            .Where(di => di.NovedadId == DataId && di.PQRSRecordId == RecordId)
                //                            .Select(di => new PQRSTimeLineViewModel.FormatoItems
                //                            {
                //                                Id = di.Id,
                //                                ItemId = di.ItemId,
                //                                Cantidad = di.Cantidad,
                //                                Precio = di.Precio,
                //                                NroFactura = di.NroFactura,
                //                                NroGuia = di.NroGuia,
                //                                MotivoPQRSId = di.MotivoPQRSId,
                //                                ComentarioAdicional = di.ComentarioAdicional,
                //                                Estado = di.Estado,
                //                                CantidadRecibida = di.CantidadRecibida,
                //                                CantidadSubida = di.CantidadSubida,
                //                                ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                //                                DocSoporte = di.DocSoporte,
                //                                MotivoPQRS = di.MotivoPQRS,
                //                                Items = di.Items
                //                            })
                //                            .ToListAsync();
                formatoItems = new List <PQRSTimeLineViewModel.FormatoItems>();
            }
            else
            {
                formato      = new List <PQRSTimeLineViewModel.Formato>();
                formatoItems = new List <PQRSTimeLineViewModel.FormatoItems>();
            }

            var Comentarios = await db.Database.SqlQuery <ComentariosRptTimeLine>($"SELECT Titulo = isnull('Step: ' + p.FlujoPQRSNombre,'General Comment'), " +
                                                                                  "Fecha = c.FechaCreacion, UsuarioId = U.UsuarioId + '-' + U.UsuarioNombre, " +
                                                                                  "c.Comentario, " +
                                                                                  "CASE c.TipoComentario " +
                                                                                  "    WHEN 1 THEN '#4CAF50' " +
                                                                                  "    WHEN 2 THEN '#F44336' " +
                                                                                  "    WHEN 3 THEN '#9E9E9E' " +
                                                                                  "    WHEN 4 THEN '#FFC107' " +
                                                                                  "    ELSE '#9E9E9E' " +
                                                                                  "END AS Color, " +
                                                                                  "CASE c.TipoComentario " +
                                                                                  "    WHEN 1 THEN 'Done' " +
                                                                                  "    WHEN 2 THEN 'Returned' " +
                                                                                  "    WHEN 3 THEN 'Comment' " +
                                                                                  "    WHEN 4 THEN 'Closed' " +
                                                                                  "    ELSE '' " +
                                                                                  "END AS Tipo " +
                                                                                  "FROM PQRSRecordComentario AS C " +
                                                                                  "    INNER JOIN Usuario AS U ON C.UsuarioId = U.UsuarioId " +
                                                                                  "    LEFT JOIN PQRSRecord AS P ON C.PQRSRecordId = P.Id AND C.PQRSRecordOrder = P.[Order] " +
                                                                                  $"WHERE PQRSRecordId = {RecordId} ORDER BY FechaCreacion").ToListAsync();


            ReportDataSource formatoDS      = new ReportDataSource("Formato", formato);
            ReportDataSource formatoItemsDS = new ReportDataSource("FormatoItems", formatoItems);
            ReportDataSource ComentariosDS  = new ReportDataSource("Comentarios", Comentarios);

            lr.DataSources.Add(formatoDS);
            lr.DataSources.Add(formatoItemsDS);
            lr.DataSources.Add(ComentariosDS);

            string reportType = archivo;
            string mimeType;
            string encoding;
            string fileNameExtension;
            //string deviceInfo =

            //     "<DeviceInfo>" +
            //            "  <OutputFormat>" + archivo + "</OutputFormat>" +
            //            "  <PageWidth>8.5in</PageWidth>" +
            //            "  <PageHeight>11in</PageHeight>" +
            //            "  <MarginTop>0.5in</MarginTop>" +
            //            "  <MarginLeft>1in</MarginLeft>" +
            //            "  <MarginRight>1in</MarginRight>" +
            //            "  <MarginBottom>0.5in</MarginBottom>" +
            //            "</DeviceInfo>";
            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>" + archivo + "</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>1in</MarginLeft>" +
                "  <MarginRight>0.5in</MarginRight>" +
                "  <MarginBottom>0in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;
            renderedBytes = lr.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            return(File(renderedBytes, mimeType));
        }
Exemple #6
0
        public async Task <ActionResult> AsignarAnalista(TipoPQRS tipo, int DataId)
        {
            var data = new AsignarAnalistaViewModel();

            data.TipoPQRS = tipo;
            data.DataId   = DataId;

            if (tipo == TipoPQRS.Devolucion)
            {
                var devolucion = await db.Devoluciones
                                 .Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (devolucion == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto     = " Subject: " + devolucion.Asunto;
                data.AnalistaId = devolucion.AnalistaId;
            }
            else if (tipo == TipoPQRS.Garantia)
            {
                var garantia = await db.Garantias.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (garantia == null)
                {
                    return(HttpNotFound());
                }

                data.Asunto     = " Subject: " + garantia.Asunto;
                data.AnalistaId = garantia.AnalistaId;
            }
            else if (tipo == TipoPQRS.Novedad)
            {
                var novedad = await db.Novedad.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (novedad == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto     = " Subject: " + novedad.Asunto;
                data.AnalistaId = novedad.AnalistaId;
            }
            else if (tipo == TipoPQRS.Recruitment)
            {
                var recruitment = await db.Recruitments.Where(d => d.RecruitmentId == DataId).FirstOrDefaultAsync();

                if (recruitment == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto     = " Subject: " + recruitment.Appointment;
                data.AnalistaId = recruitment.AnalistaId;
            }
            else
            {
                return(HttpNotFound());
            }

            return(PartialView("_AsignarAnalista", data));
        }
Exemple #7
0
        public async Task <ActionResult> AddComment(TipoPQRS TipoPQRS, int DataId, int RecordId)
        {
            var data = new AddCommentViewModel();

            data.TipoPQRS     = TipoPQRS;
            data.PQRSRecordId = RecordId;

            if (TipoPQRS == TipoPQRS.Devolucion)
            {
                var devolucion = await db.Devoluciones
                                 .Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (devolucion == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = " Subject: " + devolucion.Asunto;
                //data.AnalistaId = devolucion.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Garantia)
            {
                var garantia = await db.Garantias.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (garantia == null)
                {
                    return(HttpNotFound());
                }

                data.Asunto = " Subject: " + garantia.Asunto;
                // data.AnalistaId = garantia.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Novedad)
            {
                var novedad = await db.Novedad.Where(d => d.Id == DataId).FirstOrDefaultAsync();

                if (novedad == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = " Subject: " + novedad.Asunto;
                // data.AnalistaId = novedad.AnalistaId;
            }
            else if (TipoPQRS == TipoPQRS.Recruitment)
            {
                var recruitment = await db.Recruitments.Where(d => d.RecruitmentId == DataId).FirstOrDefaultAsync();

                if (recruitment == null)
                {
                    return(HttpNotFound());
                }


                data.Asunto = " Subject: " + recruitment.Appointment;
                // data.AnalistaId = novedad.AnalistaId;
            }
            else
            {
                return(HttpNotFound());
            }

            ViewBag.TipoDocSoporteId = await db.TipoDocSoporte.ToListAsync();

            return(PartialView("_AddComment", data));
        }
Exemple #8
0
        public async Task <ActionResult> Details(TipoPQRS TipoPQRS, int DataId, int RecordId)
        {
            var data = new PQRSTimeLineViewModel();

            if (TipoPQRS == TipoPQRS.Devolucion)
            {
                data.formato = await db.Devoluciones
                               .Include(d => d.UsuarioCreacion)
                               .Include(d => d.Analista)
                               .Where(d => d.Id == DataId)
                               .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.Id,
                    FechaCreacion     = d.FechaCreacion,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = TipoPersona.Otro,
                    Persona           = "",
                    ClienteId         = d.ClienteId,
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Asunto,
                    Observacion       = d.Observacion,
                    Destinatarios     = d.Destinatarios,
                    NroTracking       = d.NroTracking
                })
                               .FirstOrDefaultAsync();

                data.formatoArchivos = await db.DevolucionArchivos
                                       .Where(di => di.DevolucionId == DataId)
                                       .Select(da => new PQRSTimeLineViewModel.Comentarios.Archivos {
                    Item = da.Order, FileName = da.FileName
                })
                                       .ToListAsync();

                data.formatoItems = await db.DevolucionItems
                                    .Include(di => di.MotivoPQRS)
                                    .Include(di => di.Items)
                                    .Where(di => di.DevolucionId == DataId && di.PQRSRecordId == RecordId)
                                    .Select(di => new PQRSTimeLineViewModel.FormatoItems
                {
                    Id                        = di.Id,
                    ItemId                    = di.ItemId,
                    Cantidad                  = di.Cantidad,
                    Precio                    = di.Precio,
                    NroFactura                = di.NroFactura,
                    NroGuia                   = di.NroGuia,
                    MotivoPQRSId              = di.MotivoPQRSId,
                    ComentarioAdicional       = di.ComentarioAdicional,
                    Estado                    = di.Estado,
                    CantidadRecibida          = di.CantidadRecibida,
                    CantidadSubida            = di.CantidadSubida,
                    ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                    DocSoporte                = di.DocSoporte,
                    MotivoPQRS                = di.MotivoPQRS,
                    Items                     = di.Items
                })
                                    .ToListAsync();
            }
            else if (TipoPQRS == TipoPQRS.Garantia)
            {
                data.formato = await db.Garantias
                               .Include(d => d.UsuarioCreacion)
                               .Include(d => d.Analista)
                               .Where(d => d.Id == DataId)
                               .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.Id,
                    FechaCreacion     = d.FechaCreacion,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = TipoPersona.Otro,
                    Persona           = "",
                    ClienteId         = d.ClienteId,
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Asunto,
                    Observacion       = d.Observacion,
                    Destinatarios     = d.Destinatarios,
                    NroTracking       = d.NroTracking
                }).FirstOrDefaultAsync();

                data.formatoArchivos = await db.GarantiaArchivos
                                       .Where(di => di.GarantiaId == DataId)
                                       .Select(da => new PQRSTimeLineViewModel.Comentarios.Archivos {
                    Item = da.Order, FileName = da.FileName
                })
                                       .ToListAsync();

                data.formatoItems = await db.GarantiaItems
                                    .Include(di => di.MotivoPQRS)
                                    .Include(di => di.Items)
                                    .Where(di => di.GarantiaId == DataId && di.PQRSRecordId == RecordId)
                                    .Select(di => new PQRSTimeLineViewModel.FormatoItems
                {
                    Id                        = di.Id,
                    ItemId                    = di.ItemId,
                    Cantidad                  = di.Cantidad,
                    Precio                    = di.Precio,
                    NroFactura                = di.NroFactura,
                    NroGuia                   = di.NroGuia,
                    MotivoPQRSId              = di.MotivoPQRSId,
                    ComentarioAdicional       = di.ComentarioAdicional,
                    Estado                    = di.Estado,
                    CantidadRecibida          = di.CantidadRecibida,
                    CantidadSubida            = di.CantidadSubida,
                    ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                    DocSoporte                = di.DocSoporte,
                    MotivoPQRS                = di.MotivoPQRS,
                    Items                     = di.Items
                })
                                    .ToListAsync();
            }
            else if (TipoPQRS == TipoPQRS.Novedad)
            {
                data.formato = await db.Novedad
                               .Include(d => d.UsuarioCreacion)
                               .Include(d => d.Analista)
                               .Where(d => d.Id == DataId)
                               .Select(d => new PQRSTimeLineViewModel.Formato
                {
                    TipoPQRS          = TipoPQRS,
                    Id                = d.Id,
                    FechaCreacion     = d.FechaCreacion,
                    UsuarioIdCreacion = d.UsuarioCreacion.UsuarioNombre,
                    Estado            = d.Estado,
                    Prioridad         = Prioridad.Baja,
                    TipoPersona       = d.TipoPersona,
                    Persona           = d.Persona,
                    ClienteId         = d.ClienteId,
                    AnalistaId        = d.Analista.UsuarioNombre,
                    Asunto            = d.Asunto,
                    Observacion       = d.Observacion,
                    Destinatarios     = d.Destinatarios,
                    NroTracking       = d.NroTracking
                }).FirstOrDefaultAsync();

                data.formatoArchivos = await db.NovedadArchivo
                                       .Where(di => di.NovedadId == DataId)
                                       .Select(da => new PQRSTimeLineViewModel.Comentarios.Archivos {
                    Item = da.Order, FileName = da.FileName
                })
                                       .ToListAsync();

                data.formatoItems = await db.NovedadItem
                                    .Include(di => di.MotivoPQRS)
                                    .Include(di => di.Items)
                                    .Where(di => di.NovedadId == DataId && di.PQRSRecordId == RecordId)
                                    .Select(di => new PQRSTimeLineViewModel.FormatoItems
                {
                    Id                        = di.Id,
                    ItemId                    = di.ItemId,
                    Cantidad                  = di.Cantidad,
                    Precio                    = di.Precio,
                    NroFactura                = di.NroFactura,
                    NroGuia                   = di.NroGuia,
                    MotivoPQRSId              = di.MotivoPQRSId,
                    ComentarioAdicional       = di.ComentarioAdicional,
                    Estado                    = di.Estado,
                    CantidadRecibida          = di.CantidadRecibida,
                    CantidadSubida            = di.CantidadSubida,
                    ComentarioEstadoMercancia = di.ComentarioEstadoMercancia,
                    DocSoporte                = di.DocSoporte,
                    MotivoPQRS                = di.MotivoPQRS,
                    Items                     = di.Items
                })
                                    .ToListAsync();
            }
            //Lista de pasos.
            var PQRSRecords = await db.PQRSRecords
                              .Include(p => p.PQRSRecordUsuarios)
                              .Where(pr => pr.Id == RecordId).ToListAsync();

            data.PQRSRecords = PQRSRecords;



            //Lista de comentarios
            var PQRSRecordComentarios = await db.PQRSRecordComentarios
                                        .Include(pc => pc.Usuario)
                                        .Where(pc => pc.PQRSRecordId == RecordId).ToListAsync();

            List <PQRSTimeLineViewModel.Comentarios> Comentarios = new List <PQRSTimeLineViewModel.Comentarios>();

            foreach (var c in PQRSRecordComentarios)
            {
                PQRSTimeLineViewModel.Comentarios comentario = new PQRSTimeLineViewModel.Comentarios();
                comentario.PQRSRecordComentarios = c;
                comentario.PQRSRecordDocumentos  = await db.PQRSRecordDocumentos
                                                   .Include(pd => pd.TipoDocSoporte)
                                                   .Where(pd => pd.PQRSRecordComentarioId == c.Id).ToListAsync();

                comentario.PQRSRecordArchivos = await db.PQRSRecordArchivos
                                                .Where(pa => pa.PQRSRecordComentarioId == c.Id)
                                                .Select(pa => new PQRSTimeLineViewModel.Comentarios.Archivos {
                    Id = pa.PQRSRecordComentarioId, Item = pa.Item, FileName = pa.FileName
                }).ToListAsync();

                Comentarios.Add(comentario);
            }
            data.PQRSRecordComentarios = Comentarios;

            return(View(data));
        }
Exemple #9
0
        public void SendNotificationEmailTask(TipoNotificacion tipoNotificacion, TipoComentario tipoComentario, TipoPQRS tipoPQRS, int RecordId, int Order, int DataId, int CommentId, string UsuarioNombre, string AppLink)
        {
            var formato = new Formato();

            try
            {
                formato = db.Recruitments.Include(d => d.UsuarioCreacion).Include(d => d.Analista).Where(d => d.RecruitmentId == DataId)
                          .Select(d => new Formato {
                    TipoPQRS       = tipoPQRS,
                    Id             = d.RecruitmentId,
                    AnalistaId     = (d.Analista == null) ? "" : d.Analista.UsuarioNombre,
                    AnalistaCorreo = (d.Analista == null) ? "" : d.Analista.UsuarioCorreo,
                    NroTracking    = (d.NroTracking == null) ? "" : d.NroTracking
                }).FirstOrDefault();

                List <Mails> mails = new List <Mails>();

                string subject = "AIS - ";
                subject += $"[{formato.NroTracking}]: {formato.Asunto}  ({tipoNotificacion.ToString()})";
                string msg    = $"The user <b>{UsuarioNombre}</b> ";
                string action = "Details";


                bool flagDestinatarios = false;
                //Primer paso ( se crear el ticket de PQRS)
                if (tipoNotificacion == TipoNotificacion.CreateFormat)
                {
                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";
                    flagDestinatarios = true;
                }
                else if (tipoNotificacion == TipoNotificacion.Assign)
                {
                    /* msg += $"has assigned a new CS analyst ({formato.AnalistaId})";
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     * var step = db.PQRSRecords.Where(r => r.Id == RecordId && r.Order == Order).FirstOrDefault();
                     * msg += $"<b>Reason</b>: {step.MotivoPQRSNombre}<br />";
                     * var comment = db.PQRSRecordComentarios.Where(c => c.Id == CommentId).FirstOrDefault();
                     * msg += $"<b>Date Comment</b>: {comment.FechaCreacion}<br />";
                     * msg += $"<b>Comment</b>: {comment.Comentario}<br />";
                     * flagDestinatarios = step.EnviaCorreoDestinatarios ?? false;*/

                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";
                }
                else if (tipoNotificacion == TipoNotificacion.Comment)
                {
                    /* msg += $"has added a new comment";
                     *
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     *
                     * var comment = db.PQRSRecordComentarios.Where(c => c.Id == CommentId).FirstOrDefault();
                     * msg += $"<b>Date Comment</b>: {comment.FechaCreacion}<br />";
                     * msg += $"<b>Comment</b>: {comment.Comentario}<br />";*/

                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";
                }
                else if (tipoNotificacion == TipoNotificacion.CurrentStep)
                {
                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";

                    /*
                     * var step = db.PQRSRecords.Where(r => r.Id == RecordId && r.Order == Order).FirstOrDefault();
                     * if (tipoComentario == TipoComentario.Approval)
                     * {
                     *  msg += $"has approved <b>Step:</b> {step.FlujoPQRSNombre} <b>Reason PQRS:</b> {step.MotivoPQRSNombre}";
                     * }
                     * else if (tipoComentario == TipoComentario.Rejection)
                     * {
                     *  msg += $"has rejected <b>Step:</b> {step.FlujoPQRSNombre} <b>Reason PQRS:</b> {step.MotivoPQRSNombre}";
                     * }
                     *
                     *
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     * msg += $"<b>Reason</b>: {step.MotivoPQRSNombre}<br />";
                     * var comment = db.PQRSRecordComentarios.Where(c => c.Id == CommentId).FirstOrDefault();
                     * msg += $"<b>Date Comment</b>: {comment.FechaCreacion}<br />";
                     * msg += $"<b>Comment</b>: {comment.Comentario}<br />";
                     * var userStep = db.PQRSRecordUsuarios
                     *                      .Include(ru => ru.Usuario)
                     *                      .Where(ru => ru.PQRSRecordId == RecordId && ru.PQRSRecordOrder == Order).ToList();
                     * foreach (var u in userStep)
                     * {
                     *  mails.Add(new Mails { to = u.Usuario.UsuarioCorreo, toName = u.Usuario.UsuarioNombre });
                     * }
                     * flagDestinatarios = step.EnviaCorreoDestinatarios ?? false;
                     */
                }
                else if (tipoNotificacion == TipoNotificacion.NextStep)
                {
                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";

                    /*
                     * var step = db.PQRSRecords.Where(r => r.Id == RecordId && r.Order == Order).FirstOrDefaultAsync();
                     * msg = $"You have pending an action to do in system, please log in here to continue";
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     *
                     * var userStep = db.PQRSRecordUsuarios
                     *                      .Include(ru => ru.Usuario)
                     *                      .Where(ru => ru.PQRSRecordId == RecordId && ru.PQRSRecordOrder == Order).ToList();
                     * mails.Clear();
                     * foreach (var u in userStep)
                     * {
                     *  mails.Add(new Mails { to = u.Usuario.UsuarioCorreo, toName = u.Usuario.UsuarioNombre });
                     * }
                     * flagDestinatarios = false;
                     */
                }
                else if (tipoNotificacion == TipoNotificacion.Close)
                {
                    /*
                     * var step = db.PQRSRecords.Where(r => r.Id == RecordId && r.Order == Order).FirstOrDefault();
                     * msg = $"has closed  <b>Reason PQRS:</b> {step.MotivoPQRSNombre}";
                     * var comment = db.PQRSRecordComentarios.Where(c => c.Id == CommentId).FirstOrDefault();
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     * msg += $"<b>Date Comment</b>: {comment.FechaCreacion}<br />";
                     * msg += $"<b>Comment</b>: {comment.Comentario}<br />";
                     * flagDestinatarios = step.EnviaCorreoDestinatarios ?? false;
                     */
                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";
                }
                else if (tipoNotificacion == TipoNotificacion.Complete)
                {
                    /*
                     * var step = db.PQRSRecords.Where(r => r.Id == RecordId && r.Order == Order).FirstOrDefault();
                     * msg += $"has completed  ";
                     *
                     * msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                     * msg += $"<b>Date</b>: {formato.FechaCreacion}<br />";
                     * msg += $"<b>Priority</b>: {formato.Prioridad.ToString()}<br />";
                     * msg += $"<b>Note</b>: {formato.Observacion}<br />";
                     *
                     * flagDestinatarios = step.EnviaCorreoDestinatarios ?? false;
                     */
                    msg += $"has created a new Recruitment({formato.TipoPQRS.ToString()})";
                    msg += $"<br /><br /><b>PQRS Information</b><br /><br />";
                    msg += $"<b>Testecorreo</b>: {formato.AnalistaCorreo}<br />";
                    msg += $"<b>Testeanalista</b>: {formato.AnalistaId}<br />";
                    msg += $"<b>Traking</b>: {formato.NroTracking}<br />";
                    msg += $"<b>Recruitment</b>: {formato.Id}<br />";
                }

                //Destinatario del formato
                if (flagDestinatarios)
                {
                    var destinatarios = formato.Destinatarios.Split(',');
                    foreach (var d in destinatarios)
                    {
                        if (d != null && d != "")
                        {
                            mails.Add(new Mails {
                                to = d, toName = d
                            });
                        }
                    }
                }

                //if (tipoNotificacion != TipoNotificacion.CreateFormat)
                msg += $"<br /><br /><a style='color:#22BCE5' href={{url}}/PQRS/{action}?TipoPQRS={tipoPQRS}&DataId={DataId}&RecordId={RecordId}>Click here to view the PQRS.</a>";

                foreach (var m in mails)
                {
                    Task.Run(() => Fn.SendHtmlEmail("*****@*****.**", "Cayo Diebe", subject, msg, AppLink));
                    //Task.Run(() => Fn.SendHtmlEmail(m.to, m.toName, subject, msg, AppLink));
                }
            }
            catch
            {
                return;
            }

            // await Task.Run(() => Fn.SendHtmlEmail(to, toName, subject, msg));
        }
Exemple #10
0
        public async Task <IHttpActionResult> CreaPQRSRecord(TipoPQRS TipoPQRS, int id)
        {
            var dataDist = new List <PQRSMotivoViewModel>();

            //Tipo Recrutamento
            if (TipoPQRS == TipoPQRS.Recruitment)
            {
                dataDist = await db.Recruitments.Where(r => r.RecruitmentId == id).
                           Select(RE => new PQRSMotivoViewModel()
                {
                    DataId = RE.RecruitmentId, MotivoPQRSId = 29, PQRSRecordId = RE.RecruitmentId
                }).
                           Distinct().ToListAsync();
            }

            try
            {
                if (dataDist.Count == 0)
                {
                    return(Ok(false));
                }
                //Consecutivo del flujo
                int idx = 1;

                //Recorre data
                foreach (var item in dataDist)
                {
                    var flujo = await db.FlujosPQRS.Include(f => f.MotivoPQRS).Where(f => f.MotivoPQRSId == item.MotivoPQRSId).ToListAsync();

                    idx = 1;
                    idx = await db.Database.SqlQuery <int>("select isnull(max(id),0) from PQRSRecord").FirstOrDefaultAsync() + 1;

                    int CommentId = 0;

                    foreach (var f in flujo)
                    {
                        //1.  Crea record
                        PQRSRecord nPQRS = new PQRSRecord();
                        nPQRS.Id    = idx;
                        nPQRS.Order = f.Order;
                        PQRSRecordComentario nPQRSComment = new PQRSRecordComentario();
                        if (f.Id == 1)
                        {
                            //nPQRS.EstadoStep = EstadoStep.Approved;
                            nPQRS.EstadoStep = EstadoStep.Done;
                            nPQRS.PasoActual = false;
                            //Crear Comment (primer paso Success)
                            nPQRSComment.PQRSRecordId    = nPQRS.Id;
                            nPQRSComment.PQRSRecordOrder = nPQRS.Order;
                            nPQRSComment.UsuarioId       = Seguridadcll.Usuario.UsuarioId;
                            nPQRSComment.FechaCreacion   = DateTime.Now;
                            nPQRSComment.Comentario      = f.Nombre + " Formato:" + f.MotivoPQRS.TipoPQRS.ToString() + " Motivo:" + f.MotivoPQRS.Nombre;
                            nPQRSComment.TipoComentario  = TipoComentario.Approval;
                            db.PQRSRecordComentarios.Add(nPQRSComment);
                            // await db.SaveChangesAsync();
                            AddLog("", nPQRS.Id, nPQRSComment);
                        }
                        else if (f.Id == 2)
                        {
                            nPQRS.EstadoStep = EstadoStep.In_Process;
                            nPQRS.PasoActual = true;
                        }
                        else
                        {
                            nPQRS.EstadoStep = EstadoStep.Pending;
                            nPQRS.PasoActual = false;
                        }

                        nPQRS.MotivoPQRSId             = f.MotivoPQRSId;
                        nPQRS.TipoPQRS                 = TipoPQRS;
                        nPQRS.MotivoPQRSNombre         = f.MotivoPQRS.Nombre;
                        nPQRS.FlujoPQRSNombre          = f.Nombre;
                        nPQRS.FlujoPQRSTipoPaso        = f.TipoPaso;
                        nPQRS.EnviaCorreoDestinatarios = f.EnviaCorreoDestinatarios;
                        nPQRS.FlujoPQRSDescripcion     = f.Descripcion;
                        db.PQRSRecords.Add(nPQRS);
                        await db.SaveChangesAsync();

                        if (nPQRSComment != null)
                        {
                            CommentId = nPQRSComment.Id;
                        }

                        AddLog("", nPQRS.Id, nPQRS);
                        //crea record usuarios
                        var flujoUsuarios = await db.UsuarioFlujoPQRS.Where(uf => uf.MotivoPQRSId == f.MotivoPQRSId && uf.FlujoPQRSId == f.Id).ToListAsync();

                        foreach (var uf in flujoUsuarios)
                        {
                            PQRSRecordUsuario nPQRSUser = new PQRSRecordUsuario();
                            if (uf.UsuarioId == Seguridadcll.Configuracion.UsuarioVendedorPQRS)
                            {
                                string usuarioVendedor = "";
                                usuarioVendedor = await db.Novedad.Include(d => d.Cliente).Where(d => d.Id == id).Select(d => d.Cliente.VendedorId).FirstOrDefaultAsync();

                                nPQRSUser.UsuarioId = usuarioVendedor;
                            }
                            else
                            {
                                nPQRSUser.UsuarioId = uf.UsuarioId;
                            }

                            nPQRSUser.PQRSRecordId    = nPQRS.Id;
                            nPQRSUser.PQRSRecordOrder = nPQRS.Order;

                            nPQRSUser.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Unanswered;

                            db.PQRSRecordUsuarios.Add(nPQRSUser);
                            await db.SaveChangesAsync();

                            AddLog("", nPQRSUser.UsuarioId, nPQRSUser);
                        }

                        //Tareas
                        var Tareas = await db.FlujoPQRSTareas.Where(uf => uf.MotivoPQRSId == f.MotivoPQRSId && uf.FlujoPQRSId == f.Id).ToListAsync();

                        foreach (var t in Tareas)
                        {
                            PQRSRecordTareas nTarea = new PQRSRecordTareas();
                            //nTarea.Id = t.Id;
                            nTarea.PQRSRecordId    = nPQRS.Id;
                            nTarea.PQRSRecordOrder = nPQRS.Order;
                            nTarea.Descripcion     = t.Descripcion;
                            nTarea.Requerido       = t.Requerido;
                            nTarea.Terminado       = false;

                            db.PQRSRecordTareas.Add(nTarea);
                            await db.SaveChangesAsync();

                            AddLog("", nTarea.Id, nTarea);
                        }


                        //Condiciones
                        var Condiciones = await db.FlujoPQRSCondiciones.Where(uf => uf.MotivoPQRSId == f.MotivoPQRSId && uf.FlujoPQRSId == f.Id).ToListAsync();

                        foreach (var c in Condiciones)
                        {
                            PQRSRecordCondiciones nCondicion = new PQRSRecordCondiciones();
                            nCondicion.Id               = c.Id;
                            nCondicion.PQRSRecordId     = nPQRS.Id;
                            nCondicion.PQRSRecordOrder  = nPQRS.Order;
                            nCondicion.Descripcion      = c.Descripcion;
                            nCondicion.TipoCondicion    = c.TipoCondicion;
                            nCondicion.CondicionesValor = c.CondicionesValor;
                            nCondicion.Valor            = c.Valor;
                            nCondicion.SiNo             = c.SiNo;
                            nCondicion.RespValor        = 0;
                            nCondicion.RespSiNo         = false;

                            db.PQRSRecordCondiciones.Add(nCondicion);
                            await db.SaveChangesAsync();

                            AddLog("", nCondicion.Id, nCondicion);
                        }


                        //

                        if (f.Id == 4)
                        {
                            SendNotificationEmailTask(TipoNotificacion.NextStep, TipoComentario.Approval, TipoPQRS, nPQRS.Id, nPQRS.Order, dataDist.FirstOrDefault().DataId, nPQRSComment.Id, Seguridadcll.Usuario.UsuarioNombre, Seguridadcll.Aplicacion.Link);
                        }
                    }

                    if (TipoPQRS == TipoPQRS.Recruitment)
                    {
                        var itemsdev = await db.Recruitments.Where(di => di.RecruitmentId == item.DataId && 29 == item.MotivoPQRSId).ToListAsync();

                        foreach (var itemD in itemsdev)
                        {
                            itemD.PQRSRecordId    = idx;
                            db.Entry(itemD).State = EntityState.Modified;
                            await db.SaveChangesAsync();

                            AddLog("", itemD.RecruitmentId, itemD);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(Ok(true));
        }