Пример #1
0
        public async Task <bool> NotificateParticipants(Functionary Responsable, Functionary Destinatario, Tasks Tarea, string link)
        {
            var body = "<p>El Funcionario" + Responsable.Nombre + " " + Responsable.Apellido + " ha subido un Documento en la Tarea </p>"
                       + "<p>" + link + "</p>";
            var message = new MailMessage();

            message.To.Add(new MailAddress(Destinatario.MailInstitucional));
            message.To.Add(new MailAddress(Destinatario.CorreoPersonal)); // replace with valid value
            message.From       = new MailAddress(clientMail);             // replace with valid value
            message.Subject    = "Notificación SMGPA, Funcionario ha subido documento";
            message.Body       = string.Format(body);
            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new System.Net.NetworkCredential
                {
                    UserName = clientMail,  // replace with valid value
                    Password = passwordMail // replace with valid value
                };
                smtp.Credentials = credential;
                smtp.Host        = hostMail;
                smtp.Port        = int.Parse(portMail);
                smtp.EnableSsl   = true;
                await smtp.SendMailAsync(message);
            }
            return(true);
        }
Пример #2
0
        public async Task <JsonResult> AddFunctionary(string rut, string cargo)
        {
            Entities entidad = (Entities)TempData["Entity"];
            Entities entity  = await db.Entity.FindAsync(entidad.idEntities);

            if (entity == null)
            {
                return(Json(new { sucess = false, reload = true }, JsonRequestBehavior.AllowGet));
            }
            Functionary functionary = db.Functionary.Where(f => f.Rut.Equals(rut)).FirstOrDefault();
            Functionary funcionario = entity.Involucrados.Where(fu => fu.Rut.Equals(rut)).FirstOrDefault();

            if (functionary == null || funcionario != null)
            {
                TempData["Entity"] = entity;
                return(Json(new { sucess = false }, JsonRequestBehavior.AllowGet));
            }
            string            carrera = functionary.idCareer == null ? " " : functionary.Carrera.Nombre;
            FunctionaryEntity fe      = new FunctionaryEntity {
                idEntities = entity.idEntities, idUser = functionary.idUser, Cargo = cargo
            };

            entity.FuncionarioEntidad.Add(fe);
            entity.Involucrados.Add(functionary);
            functionary.Entidades.Add(entity);
            functionary.FuncionarioEntidad.Add(fe);
            await db.SaveChangesAsync();

            TempData["Entity"] = entity;
            return(Json(new { iduser = functionary.idUser, nombre = functionary.Nombre, apellido = functionary.Apellido, carrera = carrera, sucess = true }, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        }//end getAll

        //obtiene periodos activos
        public List <Functionary> getAllActive()
        {
            String sql = "SP_GETALLFUNCTIONARYACTIVED";

            try
            {
                SqlCommand oCommand = new SqlCommand(sql);
                oCommand.CommandType = System.Data.CommandType.StoredProcedure;
                DataTable          oDataTable      = DAO.getInstance().executeQuery(oCommand);
                List <Functionary> listFunctionary = new List <Functionary>();
                foreach (DataRow oDataRow in oDataTable.Rows)
                {
                    Functionary oFunctionary = new Functionary();
                    oFunctionary.code      = Convert.ToInt32(oDataRow[0].ToString());
                    oFunctionary.id        = oDataRow[1].ToString();
                    oFunctionary.name      = oDataRow[2].ToString();
                    oFunctionary.lastName  = oDataRow[3].ToString();
                    oFunctionary.homePhone = oDataRow[4].ToString();
                    oFunctionary.cellPhone = oDataRow[5].ToString();
                    oFunctionary.email     = oDataRow[6].ToString();
                    oFunctionary.state     = Convert.ToInt16(oDataRow[7].ToString());
                    listFunctionary.Add(oFunctionary);
                }
                return(listFunctionary);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        }//getActive
Пример #4
0
        public Functionary getFunctionaryById(String pId)
        {
            String sql = "GET_FUNCTIONARY_INFO";

            try
            {
                SqlCommand oCommand = new SqlCommand(sql);
                oCommand.CommandType = System.Data.CommandType.StoredProcedure;
                oCommand.Parameters.AddWithValue("@ID", pId);
                oCommand.Parameters[0].Direction = ParameterDirection.Input;
                DataTable   oDataTable   = DAO.getInstance().executeQuery(oCommand);
                Program     oProgram     = new Program();
                Functionary oFunctionary = new Functionary();

                foreach (DataRow oDataRow in oDataTable.Rows)
                {
                    oFunctionary.id        = oDataRow[0].ToString();
                    oFunctionary.name      = oDataRow[1].ToString();
                    oFunctionary.lastName  = oDataRow[2].ToString();
                    oFunctionary.homePhone = oDataRow[3].ToString();
                    oFunctionary.cellPhone = oDataRow[4].ToString();
                    oFunctionary.email     = oDataRow[5].ToString();
                    oProgram.code          = Convert.ToInt32(oDataRow[6].ToString());
                    oFunctionary.oProgram  = oProgram;
                }
                return(oFunctionary);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        }
Пример #5
0
        } // getNextCode End

        //Insert
        public Int32 insert(Functionary oFunctionary)
        {
            String oSql = "SP_INSERTFUNCTIONARY";

            try
            {
                SqlCommand oCommand = new SqlCommand(oSql);
                oCommand.CommandType = CommandType.StoredProcedure;
                oCommand.Parameters.AddWithValue("@FUNCTIONARY_ID", oFunctionary.code);
                oCommand.Parameters[0].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@ID", oFunctionary.id);
                oCommand.Parameters[1].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@NAME", oFunctionary.name);
                oCommand.Parameters[2].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@SURNAME", oFunctionary.lastName);
                oCommand.Parameters[3].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@PHONE", oFunctionary.homePhone);
                oCommand.Parameters[4].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@CELLPHONE", oFunctionary.cellPhone);
                oCommand.Parameters[5].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@MAIL", oFunctionary.email);
                oCommand.Parameters[6].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@STATE", oFunctionary.state);
                oCommand.Parameters[7].Direction = ParameterDirection.Input;
                oCommand.Parameters.AddWithValue("@PROGRAM_ID", oFunctionary.oProgram.code);
                oCommand.Parameters[8].Direction = ParameterDirection.Input;

                return(DAO.getInstance().executeSQL(oCommand));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        } //Insert end
Пример #6
0
        public async Task <ActionResult> Functionaries(Guid?id)
        {
            List <FunctionaryEntity> involucrados = new List <FunctionaryEntity>();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Entities entity = await db.Entity.FindAsync(id);

            TempData["Entity"] = entity;
            ViewBag.Entidad    = entity.Nombre;
            ICollection <FunctionaryEntity> entidadfuncionario = db.FuncionarioEntidad.Where(e => e.idEntities.Equals(entity.idEntities)).ToList();

            foreach (FunctionaryEntity fe in entidadfuncionario)
            {
                Functionary       f  = db.Functionary.Find(fe.idUser);
                FunctionaryEntity fn = new FunctionaryEntity();
                fn.Funcionario = f;
                fn.Entidad     = fe.Entidad;
                fn.Cargo       = fe.Cargo;
                involucrados.Add(fn);
            }
            return(PartialView("_Functionaries", involucrados));
        }
Пример #7
0
        public async Task <JsonResult> DeleteFunctionary(Guid?id)
        {
            if (id == null)
            {
                return(Json(new { sucess = false, reload = true }, JsonRequestBehavior.AllowGet));
            }
            Entities entidad = (Entities)TempData["Entity"];
            Entities entity  = await db.Entity.FindAsync(entidad.idEntities);

            if (entity == null)
            {
                return(Json(new { sucess = false, JsonRequestBehavior.AllowGet }));
            }
            Functionary functionary = await db.Functionary.FindAsync(id);

            FunctionaryEntity funcionarioentidad = await db.FuncionarioEntidad.FindAsync(functionary.idUser, entity.idEntities);

            bool result = (entity.Involucrados.Remove(functionary)) ? true : false;

            db.FuncionarioEntidad.Remove(funcionarioentidad);
            string carrera = functionary.idCareer == null ? "No figura" : functionary.Carrera.Nombre;
            await db.SaveChangesAsync();

            TempData["Entity"] = entity;
            return(Json(new { iduser = functionary.idUser, nombre = functionary.Nombre, apellido = functionary.Apellido, carrera = carrera, sucess = true }, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        public ActionResult Off(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Functionary funcionario = db.Functionary.Find(id);

            ViewBag.idCareer = new SelectList(db.Career, "idCareer", "Nombre", funcionario.idCareer);
            return(View(funcionario));
        }
Пример #9
0
 public ActionResult Off([Bind(Include = "idUser,Rut,Nombre,Apellido,MailInstitucional,Contrasena,Activo,NumeroTelefono,CorreoPersonal,idCareer")] Functionary user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idCareer = new SelectList(db.Career, "idCareer", "Nombre", user.idCareer);
     return(View(user));
 }
Пример #10
0
 static void addNotification(string Cuerpo, Guid?idFunctionary, DateTime?Fecha, string URL)
 {
     using (SMGPAContext db = new SMGPAContext())
     {
         Functionary  User = db.Functionary.Find(idFunctionary);
         Notificacion n    = new Notificacion();
         n.idNotification = Guid.NewGuid();
         n.Funcionario    = User;
         n.Cuerpo         = Cuerpo;
         n.Fecha          = Fecha;
         n.UrlAction      = URL;
         User.Notificaciones.Add(n);
         db.SaveChanges();
     }
 }
Пример #11
0
        public bool sendSMS(Functionary f, string Message)
        {
            string url = "http://ida.itdchile.cl/publicSms/sendSms.html?username=evaldivia&password=evaldivia.unab&phone=" + 569 + f.NumeroTelefono + "+&message=" + Message + "&" +
                         "originator =  & custom_id = vvv";
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(string.Format(url));

            webReq.Method = "GET";
            HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();

            //I don't use the response for anything right now. But I might log the response answer later on.
            Stream       answer         = webResponse.GetResponseStream();
            StreamReader _recivedAnswer = new StreamReader(answer);

            return(true);
        }
Пример #12
0
        public async Task <bool> NotificateAll(Functionary Responsable, Functionary Destinatario, Tasks Tarea, string link, int Mensaje)
        {
            var body = "";
            var subj = "";

            if (Mensaje == 1)
            {
                body = "<p>Se le ha asignado como Responsable a la Tarea"
                       + "<p>" + link + "</p>";
                subj = "- Asignación de Tarea";
            }
            if (Mensaje == 2)
            {
                body = "<p>Se le ha asignado como Validador a la Tarea"
                       + "<p>" + link + "</p>";
                subj = "- Asignación a Tarea";
            }

            if (Mensaje == 3)
            {
                body = "<p>El Funcionario" + Responsable.Nombre + " " + Responsable.Apellido + " ha comentado la Tarea</p>"
                       + "<p>" + link + "</p>";
                subj = "- Asignación a Tarea";
            }
            var message = new MailMessage();

            message.To.Add(new MailAddress(Destinatario.MailInstitucional));
            message.To.Add(new MailAddress(Destinatario.CorreoPersonal));
            message.From       = new MailAddress(clientMail);
            message.Subject    = "Notificación SMGPA" + subj;
            message.Body       = string.Format(body);
            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new System.Net.NetworkCredential
                {
                    UserName = clientMail,  // replace with valid value
                    Password = passwordMail // replace with valid value
                };
                smtp.Credentials = credential;
                smtp.Host        = hostMail;
                smtp.Port        = int.Parse(portMail);
                smtp.EnableSsl   = true;
                await smtp.SendMailAsync(message);
            }
            return(true);
        }
Пример #13
0
        public JsonResult CheckUser(string rut)
        {
            if (rut == null)
            {
                return(Json(new { sucess = false }));
            }
            Functionary functionary = db.Functionary.Where(f => f.Rut.Equals(rut)).FirstOrDefault();

            if (functionary == null)
            {
                return(Json(new { sucess = false }));
            }
            string carrera = functionary.idCareer == null ? "No figura" : functionary.Carrera.Nombre;

            return(Json(new { iduser = functionary.idUser, nombre = functionary.Nombre, apellido = functionary.Apellido, carrera = carrera, sucess = true }, JsonRequestBehavior.AllowGet));
        }
Пример #14
0
        /* GET: Tasks
         * Get The ACTIVES and IN_PROGRESS Tasks from db
         * that match de stored user's id in the Session var
         */
        public ActionResult Tasks()
        {
            Guid idUser = (Guid)Session["UserID"];

            if (idUser == null)
            {
                RedirectToAction("LogOut", "Account");
            }
            Functionary  usuario       = db.Functionary.Find(idUser);
            List <Tasks> Tareas        = new List <Tasks>();
            List <Tasks> Tasks         = db.Task.ToList();
            List <Tasks> TasksFiltered = Tasks.Where(t => t.Estado.Equals(StatusEnum.ACTIVA) || t.Estado.Equals(StatusEnum.EN_PROGRESO)).ToList();

            foreach (Tasks t in TasksFiltered)
            {
                if (t.idFunctionary != null)
                {
                    if (t.idFunctionary.Equals(idUser))
                    {
                        Tareas.Add(t);
                    }
                }
                if (t.idResponsable != null)
                {
                    foreach (Functionary f in db.Entity.Find(t.idResponsable).Involucrados)
                    {
                        if (f.idUser.Equals(idUser))
                        {
                            Tareas.Add(t);
                        }
                    }
                }
                if (t.idEntities != null)
                {
                    foreach (Functionary f in db.Entity.Find(t.idEntities).Involucrados)
                    {
                        if (f.idUser.Equals(idUser) && !Tareas.Contains(t))
                        {
                            Tareas.Add(t);
                        }
                    }
                }
            }
            return(View(Tareas));
        }
Пример #15
0
        public ActionResult Register([Bind(Include = "idUser,Rut,Nombre,Apellido,Nombre_Apellido,MailInstitucional,Contrasena,Activo,NumeroTelefono,CorreoPersonal,idCareer")] Functionary functionary)
        {
            foreach (User u in db.User.ToList())
            {
                if (u.MailInstitucional.Equals(functionary.MailInstitucional) || functionary.CorreoPersonal.Equals(u.MailInstitucional))
                {
                    ViewBag.CIDisponible = !functionary.CorreoPersonal.Equals(u.MailInstitucional) ? "Correo institucional se encuentra en uso" : null;
                    ViewBag.CPDisponible = functionary.CorreoPersonal.Equals(u.MailInstitucional) ? "Correo Personal ingresado se encuentra en uso" : null;
                    ViewBag.idCareer     = new SelectList(db.Career, "idCareer", "Nombre", functionary.idCareer);
                    return(View());
                }
            }
            foreach (Functionary f in db.Functionary.ToList())
            {
                if (f.CorreoPersonal.Equals(functionary.CorreoPersonal))
                {
                    ViewBag.CPDisponible = "Correo Personal ingresado se encuentra en uso";
                    ViewBag.idCareer     = new SelectList(db.Career, "idCareer", "Nombre", functionary.idCareer);
                    return(View());
                }
            }
            if (ModelState.IsValid)
            {
                functionary.Contrasena = mdencoder.EncodePasswordMd5(functionary.Contrasena);
                functionary.Activo     = true;;
                functionary.idUser     = Guid.NewGuid();
                db.Functionary.Add(functionary);
                if (functionary.idCareer != null)
                {
                    Career c = db.Career.Find(functionary.idCareer);
                    if (c.idFaculty != null)
                    {
                        Faculty faculty = db.Faculty.Find(c.idFaculty);
                        faculty.Involucrados.Add(functionary);
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            ViewBag.idCareer = new SelectList(db.Career, "idCareer", "Nombre", functionary.idCareer);
            return(View(functionary));
        }
Пример #16
0
        }//end getAll

        public List <Functionary> getAllByProgram(int code)
        {
            String sql = "SP_GETALLFUNCTIONARYBYPROGRAM";

            try
            {
                SqlCommand oCommand = new SqlCommand(sql);
                oCommand.CommandType = System.Data.CommandType.StoredProcedure;
                oCommand.Parameters.AddWithValue("@PROGRAM_ID", code);
                oCommand.Parameters[0].Direction = ParameterDirection.Input;
                DataTable          oDataTable      = DAO.getInstance().executeQuery(oCommand);
                List <Functionary> listFunctionary = new List <Functionary>();
                foreach (DataRow oDataRow in oDataTable.Rows)
                {
                    Functionary oFunctionary = new Functionary();
                    Program     oProgram     = new Program();
                    oFunctionary.code      = Convert.ToInt32(oDataRow[0].ToString());
                    oFunctionary.id        = oDataRow[1].ToString();
                    oFunctionary.name      = oDataRow[2].ToString();
                    oFunctionary.lastName  = oDataRow[3].ToString();
                    oFunctionary.homePhone = oDataRow[4].ToString();
                    oFunctionary.cellPhone = oDataRow[5].ToString();
                    oFunctionary.email     = oDataRow[6].ToString();
                    oFunctionary.state     = Convert.ToInt16(oDataRow[7].ToString());
                    oProgram.code          = Convert.ToInt32(oDataRow[8].ToString());
                    oProgram.name          = oDataRow[9].ToString();
                    oFunctionary.oProgram  = oProgram;
                    listFunctionary.Add(oFunctionary);
                }
                return(listFunctionary);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        }//end getAll
Пример #17
0
        public async Task <ActionResult> UploadFile(HttpPostedFileBase fileDoc)
        {
            if (fileDoc == null)
            {
                return(Content("Error, no hay archivo seleccionado"));
            }
            if (ModelState.IsValid)
            {
                Guid  id   = (Guid)TempData["Tarea"];
                Tasks task = db.Task.Single(t => t.idTask == id);
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    if (file.ContentLength > 0)
                    {
                        var    pathToSave   = "~/uploads";
                        var    fileName     = Path.GetFileName(file.FileName);
                        int    count        = 1;
                        string fileNameOnly = Path.GetFileNameWithoutExtension(fileName);
                        string extension    = Path.GetExtension(fileName);
                        string path         = Path.GetDirectoryName(fileName);
                        string newFullPath  = fileName;
                        string absolutePath = HttpContext.Server.MapPath(pathToSave + '/' + newFullPath);
                        bool   exists       = System.IO.File.Exists(absolutePath);
                        while (System.IO.File.Exists(absolutePath))
                        {
                            string tempFileName = string.Format("{0}({1})", fileNameOnly, count++);
                            newFullPath  = Path.Combine(path, tempFileName + extension);
                            absolutePath = HttpContext.Server.MapPath(pathToSave + '/' + newFullPath);
                        }
                        string Ruta = Path.Combine(
                            Server.MapPath(pathToSave), newFullPath);
                        file.SaveAs(Ruta);
                        Document documento = new Document {
                            idDocument = Guid.NewGuid(), Path = newFullPath, idTask = task.idTask, Fecha = DateTime.Today
                        };
                        task.Documentos.Add(documento);
                        task.Estado = StatusEnum.EN_PROGRESO;
                    }
                    string       link        = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("Details", "Tasks", new { id = task.idTask });
                    Notification notificator = new Notification();
                    Functionary  user        = await db.Functionary.FindAsync((Guid)Session["UserID"]);

                    Operation Operacion = db.Operation.Find(task.idOperation);
                    if (Operacion.Validable)
                    {
                        foreach (Functionary f in task.Participantes.Involucrados)
                        {
                            if (f.idUser != user.idUser)
                            {
                                Notificacion n = new Notificacion();
                                n.idNotification = Guid.NewGuid();
                                n.Fecha          = DateTime.Now;
                                n.Funcionario    = f;
                                n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha subido un Documento en la Tarea: " + task.Operacion.Nombre;
                                n.UrlAction      = link;
                                n.Vista          = false;
                                f.Notificaciones.Add(n);
                                await notificator.NotificateParticipants(user, db.Functionary.Find(f.idUser), task, link);
                            }
                        }
                    }
                    if (Operacion.Type.Equals(OperationType.ENTIDAD))
                    {
                        foreach (Functionary f in task.ResponsableEntity.Involucrados)
                        {
                            if (f.idUser != user.idUser)
                            {
                                Notificacion n = new Notificacion();
                                n.idNotification = Guid.NewGuid();
                                n.Fecha          = DateTime.Now;
                                n.Funcionario    = f;
                                n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha subido un Documento en la Tarea: " + task.Operacion.Nombre;
                                n.UrlAction      = link;
                                n.Vista          = false;
                                f.Notificaciones.Add(n);
                                await notificator.NotificateParticipants(user, db.Functionary.Find(f.idUser), task, link);
                            }
                        }
                    }
                    if (Operacion.Type.Equals(OperationType.FUNCIONARIO))
                    {
                        task.Estado = StatusEnum.COMPLETADA;
                    }

                    db.SaveChanges();
                    Tasks updatedTask = db.Task.Find(task.idTask);
                    return(Redirect(Request.UrlReferrer.ToString()));
                }
            }
            return(HttpNotFound());
        }
Пример #18
0
        public async Task <ActionResult> AddObservation([Bind(Include = "idObservation,FechaComentario,Comentario,ValidacionEstatus")] Observation observation)
        {
            Tasks Task  = (Tasks)TempData["Task"];
            Tasks Tarea = await db.Task.FindAsync(Task.idTask);

            Functionary user = await db.Functionary.FindAsync((Guid)Session["UserID"]);

            string       link        = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("Details", "Tasks", new { id = Tarea.idTask });
            Notification notificator = new Notification();

            if (ModelState.IsValid)
            {
                observation.idObservation   = Guid.NewGuid();
                observation.FechaComentario = DateTime.Now;
                observation.Funcionario     = user;
                Tarea.Observaciones.Add(observation);
                user.Observaciones.Add(observation);
                Tarea.Estado = StatusEnum.EN_PROGRESO;
                List <Guid>        idsUsuario = new List <Guid>();
                List <Observation> Obs        = Tarea.Observaciones.ToList();
                //obtengo todas las observaciones aceptadas de tarea
                foreach (Observation o in Obs)
                {
                    if (!idsUsuario.Contains(o.Funcionario.idUser) && o.ValidacionEstatus == Validate.APROBADO)
                    {
                        idsUsuario.Add(o.Funcionario.idUser);
                    }
                }
                //se debe validar que todos los Funcionarios de la Entidad tengan observaciones sobre la Tarea
                switch (Tarea.Operacion.Type)
                {
                case OperationType.ENTIDAD:
                    bool EntidadParticipo   = false;
                    bool EntidadResponsable = false;
                    if (Tarea.Operacion.Validable)
                    {
                        foreach (Functionary f in Tarea.Participantes.Involucrados)
                        {
                            await notificator.NotificateAll(user, db.Functionary.Find(f.idUser), Tarea, link, 3);

                            Notificacion n = new Notificacion();
                            n.idNotification = Guid.NewGuid();
                            n.Fecha          = DateTime.Now;
                            n.Funcionario    = f;
                            n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha comentado la Tarea: " + Tarea.Operacion.Nombre;
                            n.UrlAction      = link;
                            n.Vista          = false;
                            f.Notificaciones.Add(n);
                        }
                        int    divisor1   = idsUsuario.Count;
                        int    dividendo1 = Tarea.Participantes.Involucrados.Count + Tarea.ResponsableEntity.Involucrados.Count;
                        double division1  = (double)divisor1 / dividendo1;
                        double resultado1 = division1 * 100.0;
                        //verificamos que al menos el 50% de los involucrados haya comentado
                        if (resultado1 >= Tarea.Operacion.PorcentajeAceptacion)
                        {
                            EntidadParticipo = true;
                        }
                        foreach (Functionary f in Tarea.ResponsableEntity.Involucrados)
                        {
                            await notificator.NotificateAll(user, db.Functionary.Find(f.idUser), Tarea, link, 3);

                            Notificacion n = new Notificacion();
                            n.idNotification = Guid.NewGuid();
                            n.Fecha          = DateTime.Now;
                            n.Funcionario    = f;
                            n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha comentado la Tarea: " + Tarea.Operacion.Nombre;
                            n.UrlAction      = link;
                            n.Vista          = false;
                            f.Notificaciones.Add(n);
                        }
                        int    divisor2   = idsUsuario.Count;
                        int    dividendo2 = Tarea.ResponsableEntity.Involucrados.Count + Tarea.Participantes.Involucrados.Count;
                        double division2  = (double)divisor2 / dividendo2;
                        double resultado2 = division2 * 100.0;
                        if (resultado2 >= Tarea.Operacion.PorcentajeAceptacion)
                        {
                            EntidadResponsable = true;
                        }
                        if (EntidadParticipo && EntidadResponsable)
                        {
                            Tarea.Estado = StatusEnum.COMPLETADA;
                        }
                    }
                    else
                    {
                        foreach (Functionary f in Tarea.ResponsableEntity.Involucrados)
                        {
                            await notificator.NotificateAll(user, db.Functionary.Find(f.idUser), Tarea, link, 3);

                            Notificacion n = new Notificacion();
                            n.idNotification = Guid.NewGuid();
                            n.Fecha          = DateTime.Now;
                            n.Funcionario    = f;
                            n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha comentado la Tarea: " + Tarea.Operacion.Nombre;
                            n.UrlAction      = link;
                            n.Vista          = false;
                            f.Notificaciones.Add(n);
                        }
                        int    divisor2   = idsUsuario.Count;
                        int    dividendo2 = Tarea.ResponsableEntity.Involucrados.Count;
                        double division2  = (double)divisor2 / dividendo2;
                        double resultado2 = division2 * 100.0;
                        if (resultado2 >= Tarea.Operacion.PorcentajeAceptacion)
                        {
                            EntidadResponsable = true;
                        }
                        if (EntidadResponsable)
                        {
                            Tarea.Estado = StatusEnum.COMPLETADA;
                        }
                    }

                    break;

                case OperationType.FUNCIONARIO:
                    bool Entidad = false;
                    if (Tarea.Operacion.Validable)
                    {
                        foreach (Functionary f in Tarea.Participantes.Involucrados)
                        {
                            await notificator.NotificateAll(user, db.Functionary.Find(f.idUser), Tarea, link, 3);

                            Notificacion n = new Notificacion();
                            n.idNotification = Guid.NewGuid();
                            n.Fecha          = DateTime.Now;
                            n.Funcionario    = f;
                            n.Cuerpo         = "El Funcionario " + user.Nombre + " " + user.Apellido + " ha comentado la Tarea: " + Tarea.Operacion.Nombre;
                            n.UrlAction      = link;
                            n.Vista          = false;
                            f.Notificaciones.Add(n);
                        }
                        int    divisor1   = idsUsuario.Count;
                        int    dividendo1 = Tarea.Participantes.Involucrados.Count;
                        double division1  = (double)divisor1 / dividendo1;
                        double resultado1 = division1 * 100.0;
                        //verificamos que al menos el 50% de los involucrados haya comentado
                        if (resultado1 >= Tarea.Operacion.PorcentajeAceptacion)
                        {
                            Entidad = true;
                        }
                        //verificamos que al menos el 50% de los involucrados haya comentado
                        if (Entidad)
                        {
                            Tarea.Estado = StatusEnum.COMPLETADA;
                        }
                    }
                    break;
                }
                await db.SaveChangesAsync();

                return(PartialView());
            }
            return(PartialView());
        }