public async Task <ActionResult> Index() { try { var token = _session.GetString("Token"); if (Seguridad.validarUsuarioAdministrativo(token)) { List <Peon> peones = await ControladoraUsuarios.getInstance(_settings).getPeones(); return(View(peones)); } else { return(RedirectToAction("Login", "Account")); } } catch (MensajeException msg) { TempData["Error"] = msg.Message; return(RedirectToAction("Index", "Home")); } catch (Exception) { TempData["Error"] = "Ha ocurrido un error inesperado, intente de nuevo mas tarde"; return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> Delete(string id, Peon peon) { try { var token = _session.GetString("Token"); if (Seguridad.validarUsuarioAdministrativo(token)) { if (ModelState.IsValid) { await ControladoraUsuarios.getInstance(_settings).EliminarPeon(id); return(RedirectToAction("Index")); } return(View(peon)); } else { return(RedirectToAction("Login", "Account")); } } catch (MensajeException msg) { TempData["Error"] = msg.Message; return(RedirectToAction("Index")); } catch (Exception) { TempData["Error"] = "Ha ocurrido un error inesperado, intente de nuevo mas tarde"; return(RedirectToAction("Index")); } }
public ViewModelViajeDirecto(IOptions <AppSettingsMongo> settings) { _settings = settings; _controladoraUsuarios = ControladoraUsuarios.getInstance(_settings); _controladoraVehiculos = ControladoraVehiculos.getInstance(_settings); cargarClientes().Wait(); cargarVehiculos(); }
public ChoferController(IOptions <AppSettingsMongo> settings, IHttpContextAccessor httpContextAccessor, IConfiguration configuration) { _session = httpContextAccessor.HttpContext.Session; _configuration = configuration; _httpContext = httpContextAccessor; _settings = settings; _controladoraUsuarios = ControladoraUsuarios.getInstance(_settings); }
public AdministrativoController(IOptions <AppSettingsMongo> settings, IHttpContextAccessor httpContextAccessor, IConfiguration configuration) { _session = httpContextAccessor.HttpContext.Session; _configuration = configuration; _httpContext = httpContextAccessor; _settings = settings; DBRepositoryMongo <Usuario> .Iniciar(_settings); _controladoraUsuarios = ControladoraUsuarios.getInstance(_settings); }
public async Task cargarClientes() { var clientes = await ControladoraUsuarios.getInstance(_settings).getClientes(); List <Cliente> lista = clientes.ToList(); Cliente c = new Cliente() { Id = new ObjectId(), Leyenda = "Seleccione un cliente" }; lista.Insert(0, c); Clientes = new SelectList(lista, "Id", "Leyenda"); }
public APIController(IOptions <AppSettingsMongo> settings, IHttpContextAccessor httpContextAccessor, IConfiguration configuration) { _session = httpContextAccessor.HttpContext.Session; _configuration = configuration; _httpContext = httpContextAccessor; _settings = settings; DBRepositoryMongo <Usuario> .Iniciar(_settings); DBRepositoryMongo <Cliente> .Iniciar(_settings); DBRepositoryMongo <Chofer> .Iniciar(_settings); _controladoraViajes = ControladoraViajes.getInstancia(_settings); _controladoraVehiculos = ControladoraVehiculos.getInstance(_settings); _controladoraUsuarios = ControladoraUsuarios.getInstance(_settings); }