Beispiel #1
0
 public ActionResult DetalleAcciones(int id)
 {
     try
     {
         ApplicationDbContext db = new ApplicationDbContext();
         var a              = User;
         var listaacciones  = db.Acciones.Where(x => x.IdProceso == id).OrderByDescending(x => x.FechaInicio).ToList();
         var userWithClaims = (ClaimsPrincipal)User;
         var idUsuario      = userWithClaims.Claims.First(c => c.Type == Constantes.IdUsuario).Value;
         var proceso        = db.Procesos.Where(x => x.IdProceso == id && x.Id == idUsuario).FirstOrDefault();
         if (proceso == null)
         {
             return(View("Error404"));
         }
         var accionesViewModel = new AccionesViewModel {
             Proceso = proceso, ListaAcciones = listaacciones
         };
         return(View(accionesViewModel));
     }
     catch (Exception)
     {
         AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         return(RedirectToAction("Login", "Account"));
     }
 }
Beispiel #2
0
        public async Task <ActionResult> InsertarAccion(AccionesViewModel accionView)
        {
            try
            {
                if (ModelState.IsValid)
                {
                }
                ApplicationDbContext db = new ApplicationDbContext();

                var accionProceso = new Accion {
                    DetalleFin = "SIN FINALIZAR", FechaFin = DateTime.Now, Estado = EstadoAcciones.EnProceso, Detalle = accionView.Detalle, FechaInicio = accionView.FechaInicio, IdProceso = accionView.Proceso.IdProceso, IdTipoAccion = accionView.IdTipoAccion
                };

                db.Acciones.Add(accionProceso);
                await db.SaveChangesAsync();

                var    proceso  = db.Procesos.Where(x => x.IdProceso == accionView.Proceso.IdProceso).FirstOrDefault();
                var    usuario  = db.Users.Where(x => x.Id == proceso.Id).FirstOrDefault();
                string htmlData = InfoMail.CreacionAccion();

                var tipoActividad = db.TipoAcciones.Where(x => x.IdTipoAccion == accionView.IdTipoAccion).FirstOrDefault();
                htmlData = htmlData.Replace("@FechaCracion", accionView.FechaInicio.ToLongDateString());
                htmlData = htmlData.Replace("@NIP", proceso.NIP);
                htmlData = htmlData.Replace("@TipoActividad", tipoActividad.Nombre);
                htmlData = htmlData.Replace("@Detalle", accionView.Detalle);
                //Send email
                EnviarCorreo.Enviar(usuario.Email, "Se ha creado una acción", htmlData);

                if (!string.IsNullOrEmpty(usuario.CorreoNotificacion_1))
                {
                    EnviarCorreo.Enviar(usuario.CorreoNotificacion_1, "Se ha creado una acción", htmlData);
                }

                if (!string.IsNullOrEmpty(usuario.CorreoNotificacion_2))
                {
                    EnviarCorreo.Enviar(usuario.CorreoNotificacion_2, "Se ha creado una acción", htmlData);
                }
                if (!string.IsNullOrEmpty(usuario.CorreoNotificacion_3))
                {
                    EnviarCorreo.Enviar(usuario.CorreoNotificacion_3, "Se ha creado una acción", htmlData);
                }
                if (!string.IsNullOrEmpty(usuario.CorreoNotificacion_4))
                {
                    EnviarCorreo.Enviar(usuario.CorreoNotificacion_4, "Se ha creado una acción", htmlData);
                }

                db.Dispose();
                return(RedirectToAction("DetalleAcciones", new { id = accionProceso.IdProceso }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        public ActionResult DetalleAcciones(int id)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            var listaacciones       = db.Acciones.Where(x => x.IdProceso == id).OrderByDescending(x => x.FechaInicio).ToList();
            var proceso             = db.Procesos.Where(x => x.IdProceso == id).FirstOrDefault();

            ViewBag.IdTipoAccion = new SelectList(db.TipoAcciones.OrderBy(x => x.Nombre), "IdTipoAccion", "Nombre");
            var accionesViewModel = new AccionesViewModel {
                Proceso = proceso, ListaAcciones = listaacciones
            };

            return(View(accionesViewModel));
        }