public async Task <IActionResult> Index(string mensaje) { InicializarMensaje(mensaje); List <ActividadesGestionCambioViewModel> lista = new List <ActividadesGestionCambioViewModel>(); var modelo = new ActividadesGestionCambioViewModel(); try { var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault(); if (claim.IsAuthenticated == true) { var token = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value; var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value; modelo.NombreUsuario = NombreUsuario; // Obtención de datos para generar pantalla lista = await apiServicio.ObtenerElementoAsync1 <List <ActividadesGestionCambioViewModel> >(modelo, new Uri(WebApp.BaseAddress), "api/ActividadesGestionCambio/ListarActividadesGestionCambio"); return(View(lista)); } return(RedirectToAction("Login", "Login")); } catch (Exception ex) { mensaje = Mensaje.Excepcion; return(View(lista)); } }
public async Task <Response> InsertarActividadesGestionCambio([FromBody] ActividadesGestionCambioViewModel actividadesGestionCambioViewModel) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido, }); } var modelo = new ActividadesGestionCambio { IdDependencia = actividadesGestionCambioViewModel.IdDependencia, IdEmpleado = actividadesGestionCambioViewModel.IdEmpleado, Avance = actividadesGestionCambioViewModel.Avance, EstadoActividadesGestionCambio = actividadesGestionCambioViewModel.ValorEstado, Tarea = actividadesGestionCambioViewModel.Tarea, FechaInicio = actividadesGestionCambioViewModel.FechaInicio, FechaFin = actividadesGestionCambioViewModel.FechaFin, Observaciones = (String.IsNullOrEmpty(actividadesGestionCambioViewModel.Observaciones)) ? "" : actividadesGestionCambioViewModel.Observaciones }; if (Existe(modelo).Result.IsSuccess) { return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } db.ActividadesGestionCambio.Add(modelo); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.GuardadoSatisfactorio }); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = Mensaje.Excepcion }); } }
public async Task <IActionResult> Edit(string mensaje, int id) { InicializarMensaje(mensaje); var modelo = new ActividadesGestionCambioViewModel(); try { modelo.IdActividadesGestionCambio = id; var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault(); if (claim.IsAuthenticated == true) { var token = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value; var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value; modelo.NombreUsuario = NombreUsuario; var objetoListas = await apiServicio.ObtenerElementoAsync1 <CrearActividadesGestionCambioViewModel>(modelo, new Uri(WebApp.BaseAddress), "api/ActividadesGestionCambio/ObtenerActividadesGestionCambioPorId"); modelo.FechaInicio = objetoListas.actividadesGestionCambioViewModel.FechaInicio; modelo.FechaFin = objetoListas.actividadesGestionCambioViewModel.FechaFin; ViewData["Estados"] = new SelectList(objetoListas.ListaEstadoActividadGestionCambioViewModel, "Valor", "Nombre"); ViewData["Dependencias"] = new SelectList(objetoListas.ListaDependenciasViewModel, "IdDependencia", "NombreDependencia"); ViewData["Empleados"] = new SelectList(objetoListas.ListaDatosBasicosEmpleadoViewModel, "IdEmpleado", "Nombres"); modelo = objetoListas.actividadesGestionCambioViewModel; return(View(modelo)); } return(RedirectToAction("Login", "Login")); } catch (Exception ex) { mensaje = Mensaje.Excepcion; return(View(modelo)); } }
public async Task <IActionResult> Edit(ActividadesGestionCambioViewModel model) { try { Response response = await apiServicio.InsertarAsync(model, new Uri(WebApp.BaseAddress), "api/ActividadesGestionCambio/EditarActividadesGestionCambio"); if (response.IsSuccess) { var mensajeResultado = response.Message; return(RedirectToAction("Index", "ActividadesGestionCambio", new { mensaje = mensajeResultado })); } return(RedirectToAction("Edit", "ActividadesGestionCambio", new { mensaje = response.Message, id = model.IdActividadesGestionCambio })); } catch (Exception ex) { return(RedirectToAction("Index", "ActivacionesPersonalTalentoHumano", new { mensaje = Mensaje.Excepcion })); } }
public async Task <JsonResult> ListarEmpleadosPorSucursalYDependencia(int idDependencia) { var modelo = new ActividadesGestionCambioViewModel(); var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault(); if (claim.IsAuthenticated == true) { var token = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value; var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value; modelo.IdDependencia = idDependencia; modelo.NombreUsuario = NombreUsuario; var empleados = await apiServicio.Listar <DatosBasicosEmpleadoViewModel>(modelo, new Uri(WebApp.BaseAddress) , "api/ActividadesGestionCambio/ObtenerEmpleadosPorSucursalYDependencia"); return(Json(empleados)); } return(Json(new List <DatosBasicosEmpleadoViewModel>())); }
public async Task <IActionResult> Index(int IdPlanGestionCambio, int IdActividadesGestionCambio) { try { if (IdPlanGestionCambio != 0 && IdActividadesGestionCambio == 0) { var actividadesGestionCambio = new ActividadesGestionCambioViewModel { IdPlanGestionCambio = Convert.ToInt32(IdPlanGestionCambio), }; var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel { IdPlanGestionCambio = Convert.ToInt32(IdPlanGestionCambio), ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan") }; return(View(viewModelActividadesGestionCambio)); } if (IdPlanGestionCambio == 0 && IdActividadesGestionCambio != 0) { var actividadesGestionCambio = new ActividadesGestionCambio { IdActividadesGestionCambio = Convert.ToInt32(IdActividadesGestionCambio), }; var respuesta = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ActividadesGestionCambioconIdActividad"); var actividades = JsonConvert.DeserializeObject <ActividadesGestionCambio>(respuesta.Resultado.ToString()); var actividadesGestionCambioViewModel = new ActividadesGestionCambioViewModel { IdPlanGestionCambio = Convert.ToInt32(actividades.IdPlanGestionCambio), }; var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel { IdPlanGestionCambio = Convert.ToInt32(actividades.IdPlanGestionCambio), ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambioViewModel, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan") }; return(View(viewModelActividadesGestionCambio)); } ViewData["Mensaje"] = "Ir a la página de Plan Gestión Cambio"; return(View("NoExisteElemento")); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Listando una actividad de gestión de cambio", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.NetActivity), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <CrearActividadesGestionCambioViewModel> CrearActividadesGestionCambio([FromBody] ActividadesGestionCambioViewModel actividadesGestionCambioViewModel) { var modelo = new CrearActividadesGestionCambioViewModel(); modelo.actividadesGestionCambioViewModel = new ActividadesGestionCambioViewModel { FechaInicio = DateTime.Now, FechaFin = DateTime.Now, Observaciones = "" }; modelo.ListaDatosBasicosEmpleadoViewModel = new List <DatosBasicosEmpleadoViewModel>(); modelo.ListaEstadoActividadGestionCambioViewModel = new List <EstadoActividadGestionCambioViewModel>(); modelo.ListaDependenciasViewModel = new List <DependenciaViewModel>(); try { var empleado = db.Empleado.Include(d => d.Dependencia) .Where(x => x.NombreUsuario == actividadesGestionCambioViewModel.NombreUsuario) .FirstOrDefault() ; // Obtención de estados desde las constantes modelo.ListaEstadoActividadGestionCambioViewModel = Constantes.ListaEstadosGestionCambio; // Obtención de los empleados por sucursal modelo.ListaDatosBasicosEmpleadoViewModel = await db.Empleado .Where(w => w.Dependencia.IdSucursal == empleado.Dependencia.IdSucursal ) .Select(s => new DatosBasicosEmpleadoViewModel { IdEmpleado = s.IdEmpleado, Nombres = s.Persona.Nombres + " " + s.Persona.Apellidos } ) .ToListAsync(); // Obtención de dependencias por sucursal modelo.ListaDependenciasViewModel = await db.Dependencia .Where(w => w.IdSucursal == empleado.Dependencia.IdSucursal ) .Select(s => new DependenciaViewModel { IdDependencia = s.IdDependencia, NombreDependencia = s.Nombre, IdSucursal = s.IdSucursal } ) .ToListAsync(); return(modelo); } catch (Exception) { return(modelo); } }
public async Task <List <ActividadesGestionCambioViewModel> > ListarActividadesGestionCambio([FromBody] ActividadesGestionCambioViewModel actividadesGestionCambioViewModel) { try { var empleado = db.Empleado.Include(d => d.Dependencia) .Where(x => x.NombreUsuario == actividadesGestionCambioViewModel.NombreUsuario) .FirstOrDefault() ; return(await db.ActividadesGestionCambio.Include(d => d.Dependencia).Include(e => e.Empleado).ThenInclude(p => p.Persona) .Where(w => w.Dependencia.IdSucursal == empleado.Dependencia.IdSucursal) .Select(x => new ActividadesGestionCambioViewModel { IdActividadesGestionCambio = x.IdActividadesGestionCambio, IdDependencia = x.IdDependencia, NombreDependencia = x.Dependencia.Nombre, IdEmpleado = x.IdEmpleado, NombreEmpleado = x.Empleado.Persona.Nombres + " " + x.Empleado.Persona.Apellidos, Avance = x.Avance, FechaInicio = x.FechaInicio, FechaFin = x.FechaFin, Observaciones = x.Observaciones, Tarea = x.Tarea, ValorEstado = x.EstadoActividadesGestionCambio, Estado = Constantes.ListaEstadosGestionCambio.Where(a => a.Valor == x.EstadoActividadesGestionCambio).FirstOrDefault().Nombre } ) .ToListAsync()); } catch (Exception ex) { return(new List <ActividadesGestionCambioViewModel>()); } }
public async Task <List <DatosBasicosEmpleadoViewModel> > ObtenerEmpleadosPorSucursalYDependencia([FromBody] ActividadesGestionCambioViewModel actividadesGestionCambioViewModel) { try { var empleado = db.Empleado.Include(d => d.Dependencia) .Where(x => x.NombreUsuario == actividadesGestionCambioViewModel.NombreUsuario) .FirstOrDefault() ; // Obtención de los empleados por sucursal var modelo = await db.Empleado .Where(w => w.Dependencia.IdSucursal == empleado.Dependencia.IdSucursal && w.IdDependencia == actividadesGestionCambioViewModel.IdDependencia ) .Select(s => new DatosBasicosEmpleadoViewModel { IdEmpleado = s.IdEmpleado, Nombres = s.Persona.Nombres + " " + s.Persona.Apellidos } ) .ToListAsync(); return(modelo); } catch (Exception ex) { return(new List <DatosBasicosEmpleadoViewModel>()); } }
public async Task <CrearActividadesGestionCambioViewModel> ObtenerActividadesGestionCambioPorId([FromBody] ActividadesGestionCambioViewModel actividadesGestionCambioViewModel) { var modelo = new CrearActividadesGestionCambioViewModel(); modelo.actividadesGestionCambioViewModel = new ActividadesGestionCambioViewModel { FechaInicio = DateTime.Now, FechaFin = DateTime.Now }; modelo.ListaDatosBasicosEmpleadoViewModel = new List <DatosBasicosEmpleadoViewModel>(); modelo.ListaEstadoActividadGestionCambioViewModel = new List <EstadoActividadGestionCambioViewModel>(); modelo.ListaDependenciasViewModel = new List <DependenciaViewModel>(); try { var empleado = db.Empleado.Include(d => d.Dependencia) .Where(x => x.NombreUsuario == actividadesGestionCambioViewModel.NombreUsuario) .FirstOrDefault() ; var idSucursal = empleado.Dependencia.IdSucursal; // Obtención de estados desde las constantes modelo.ListaEstadoActividadGestionCambioViewModel = Constantes.ListaEstadosGestionCambio; // Obtención de los empleados por sucursal modelo.ListaDatosBasicosEmpleadoViewModel = await db.Empleado .Where(w => w.Dependencia.IdSucursal == idSucursal ) .Select(s => new DatosBasicosEmpleadoViewModel { IdEmpleado = s.IdEmpleado, Nombres = s.Persona.Nombres + " " + s.Persona.Apellidos } ) .ToListAsync(); // Obtención de dependencias por sucursal modelo.ListaDependenciasViewModel = await db.Dependencia .Where(w => w.IdSucursal == empleado.Dependencia.IdSucursal ) .Select(s => new DependenciaViewModel { IdDependencia = s.IdDependencia, NombreDependencia = s.Nombre, IdSucursal = s.IdSucursal } ) .ToListAsync(); //Obtención del registro modelo.actividadesGestionCambioViewModel = await db.ActividadesGestionCambio.Include(d => d.Dependencia).Include(e => e.Empleado).ThenInclude(p => p.Persona) .Where(w => w.IdActividadesGestionCambio == actividadesGestionCambioViewModel.IdActividadesGestionCambio ) .Select(x => new ActividadesGestionCambioViewModel { IdActividadesGestionCambio = x.IdActividadesGestionCambio, IdDependencia = x.IdDependencia, NombreDependencia = x.Dependencia.Nombre, IdEmpleado = x.IdEmpleado, NombreEmpleado = x.Empleado.Persona.Nombres + " " + x.Empleado.Persona.Apellidos, Avance = x.Avance, FechaInicio = x.FechaInicio, FechaFin = x.FechaFin, Observaciones = x.Observaciones, Tarea = x.Tarea, ValorEstado = x.EstadoActividadesGestionCambio, Estado = Constantes.ListaEstadosGestionCambio.Where(a => a.Valor == x.EstadoActividadesGestionCambio).FirstOrDefault().Nombre } ) .FirstOrDefaultAsync(); return(modelo); } catch (Exception ex) { return(modelo); } }
public async Task <IActionResult> Create(ActividadesGestionCambioViewModel model) { string mensaje = ""; try { if (ModelState.IsValid) { Response response = await apiServicio.InsertarAsync(model, new Uri(WebApp.BaseAddress), "api/ActividadesGestionCambio/InsertarActividadesGestionCambio"); if (response.IsSuccess) { var mensajeResultado = response.Message; return(RedirectToAction("Index", "ActividadesGestionCambio", new { mensaje = mensajeResultado })); } mensaje = response.Message; } else { mensaje = Mensaje.ModeloInvalido; } var modelo = new ActividadesGestionCambioViewModel(); var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault(); if (claim.IsAuthenticated == true) { var token = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value; var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value; modelo.NombreUsuario = NombreUsuario; var objetoListas = await apiServicio.ObtenerElementoAsync1 <CrearActividadesGestionCambioViewModel>(modelo, new Uri(WebApp.BaseAddress), "api/ActividadesGestionCambio/CrearActividadesGestionCambio"); modelo.FechaInicio = objetoListas.actividadesGestionCambioViewModel.FechaInicio; modelo.FechaFin = objetoListas.actividadesGestionCambioViewModel.FechaFin; ViewData["Estados"] = new SelectList(objetoListas.ListaEstadoActividadGestionCambioViewModel, "Valor", "Nombre"); ViewData["Dependencias"] = new SelectList(objetoListas.ListaDependenciasViewModel, "IdDependencia", "NombreDependencia"); ViewData["Empleados"] = new SelectList(objetoListas.ListaDatosBasicosEmpleadoViewModel, "IdEmpleado", "Nombres"); InicializarMensaje(mensaje); return(View(model)); } return(RedirectToAction("Login", "Login")); } catch (Exception ex) { return(RedirectToAction("Index", "ActivacionesPersonalTalentoHumano", new { mensaje = Mensaje.Excepcion })); } }