public async Task <JsonResult> RecorridoDiario(int Id, string fechaActual) { if (Id <= 0) { return(Json(false)); } var fecha = new DateTime(); if (fechaActual == "") { fecha = DateTime.Now; } else { fecha = Convert.ToDateTime(fechaActual).Date; } var visitaDiaria = new VisitaDiaria { IdAgente = Id, Fecha = fecha }; var response = await ApiServicio.Listar <PuntosRequest>(visitaDiaria, new Uri(WebApp.BaseAddress), "Simed/api/Visitas/GetVisitasDiarias"); if (response == null || response.Count == 0) { return(Json(false)); } return(Json(response)); }
public async Task <ActionResult> Create(SalarioBasico salarioBasico) { if (!ModelState.IsValid) { return(View(salarioBasico)); } IdentityPersonalizado ci = (IdentityPersonalizado)HttpContext.User.Identity; string nombreUsuario = ci.Identity.Name; var administrador = new Administrador { Nombre = nombreUsuario }; administrador = await ProveedorAutenticacion.GetUser(administrador); salarioBasico.EmpresaId = administrador.EmpresaId; var response = await ApiServicio.InsertarAsync(salarioBasico, new Uri(WebApp.BaseAddress), "api/SalariosBasicos/CreateSalarioBasico"); if (!response.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index")); }
public async Task <ActionResult> MapaCalor() { //bUSCA LA EMPRESA var idEmpresaInt = 0; try { var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; idEmpresaInt = Convert.ToInt32(idEmpresa); } catch (Exception ex) { InicializarMensaje(Mensaje.ErrorIdEmpresa); return(View()); } //FIN MapaCalorRequest mapacalor = new MapaCalorRequest(); mapacalor.IdEmpresa = idEmpresaInt; var lista = await ApiServicio.ObtenerElementoAsync1 <MapaCalorRequest>(mapacalor, new Uri(WebApp.BaseAddress) , "api/MapaCalor/ObtenerTipoClienteTipoCompromisoPorEmpresa"); ViewBag.idTipoCliente = new SelectList(lista.ListaTipoCliente, "idTipoCliente", "Tipo"); ViewBag.IdTipoCompromiso = new SelectList(lista.ListaTipoCompromiso, "IdTipoCompromiso", "Descripcion"); return(View()); }
public async Task <ActionResult> Index(int?idEstado) { var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; var empresaActual = new EmpresaActual(); if (idEstado == null) { empresaActual = new EmpresaActual { IdEmpresa = Convert.ToInt32(idEmpresa), IdEstado = EstadoCliente.Activo }; ViewBag.IdEstadoCliente = new SelectList(ListaClientesEstados.ListaEstados, "IdEstado", "Nombre", EstadoCliente.Activo); } else { empresaActual = new EmpresaActual { IdEmpresa = Convert.ToInt32(idEmpresa), IdEstado = Convert.ToInt32(idEstado) }; ViewBag.IdEstadoCliente = new SelectList(ListaClientesEstados.ListaEstados, "IdEstado", "Nombre", Convert.ToInt32(idEstado)); } var lista = await ApiServicio.Listar <ClienteRequest>(empresaActual, new Uri(WebApp.BaseAddress) , "api/Clientes/ListarClientes"); return(View(lista)); }
public async Task <JsonResult> EditarSector(int sectorId, string nombreSector, List <Posiciones> arreglo) { if (string.IsNullOrEmpty(nombreSector) || arreglo.Count <= 2) { return(Json(false)); } var lista = new List <PuntoSector>(); foreach (var item in arreglo) { // item.latitud = item.latitud.Replace(".", ","); //item.longitud = item.longitud.Replace(".", ","); lista.Add(new PuntoSector { Latitud = Convert.ToDouble(item.latitud), Longitud = Convert.ToDouble(item.longitud) }); } var sector = new SectorViewModel { Sector = new Sector { NombreSector = nombreSector, SectorId = sectorId }, PuntoSector = lista, }; var response = await ApiServicio.InsertarAsync(sector, new Uri(WebApp.BaseAddress), "api/Sectors/EditarSector"); if (!response.IsSuccess) { return(Json(false)); } return(Json(true)); }
public async Task <ActionResult> Create(Vendedor vendedor) { if (!ModelState.IsValid) { return(View(vendedor)); } IdentityPersonalizado ci = (IdentityPersonalizado)HttpContext.User.Identity; string nombreUsuario = ci.Identity.Name; var administrador = new Administrador { Nombre = nombreUsuario }; administrador = await ProveedorAutenticacion.GetUser(administrador); var codificar = CodificarHelper.SHA512(new Codificar { Entrada = vendedor.Nombre }); vendedor.Contrasena = codificar.Salida; vendedor.EmpresaId = administrador.EmpresaId; var response = await ApiServicio.InsertarAsync(vendedor, new Uri(WebApp.BaseAddress), "api/Vendedors/CreateVendedor"); if (!response.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index", "Vendedores")); }
public async Task <JsonResult> DetalleSector(int sectorId) { if (sectorId <= 0) { return(Json(false)); } var sector = new Sector { SectorId = sectorId }; var response = await ApiServicio.Listar <PuntoSector>(sector, new Uri(WebApp.BaseAddress), "api/Sectors/GetPuntoSectorPorSector"); if (response == null) { return(Json(false)); } var listaRequest = new List <PuntosRequest>(); foreach (var item in response) { listaRequest.Add(new PuntosRequest { lat = (Double)item.Latitud, lng = (Double)item.Longitud }); } return(Json(listaRequest)); }
public JsonResult <ApiServicio> GetServicio(int id) { Servicio servicioLista = dataservServicio.GetServicio(id); ApiServicio servicios = objMap.CreateMapper().Map <ApiServicio>(servicioLista); return(Json <ApiServicio>(servicios)); }
public async Task <ActionResult> Edit(string id) { try { var super = new SupervisorRequest { IdSupervisor = Convert.ToInt32(id) }; if (!string.IsNullOrEmpty(id)) { var response = await ApiServicio.ObtenerElementoAsync(super, new Uri(WebApp.BaseAddress), "api/Supervisor/obtenerSupervisor"); response.Resultado = JsonConvert.DeserializeObject <SupervisorRequest>(response.Resultado.ToString()); if (response.IsSuccess) { InicializarMensaje(null); return(View(response.Resultado)); } } } catch (Exception ex) { ex.ToString(); } return(View()); }
public async Task <JsonResult> ClienteVendor(string idVendedor) { var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; var empresaActual = new EmpresaActual { IdEmpresa = Convert.ToInt32(idEmpresa) }; var user = new SupervisorRequest { IdVendedor = Convert.ToUInt16(idVendedor), IdEmpresa = empresaActual.IdEmpresa }; try { var respusta = await ApiServicio.ObtenerElementoAsync1 <VendedorRequest>(user, new Uri(WebApp.BaseAddress) , "api/Vendedores/ListarClientesPorVendedor"); //var a = respusta.ListaClientes.ToString(); var listaSalida = JsonConvert.DeserializeObject <List <ClienteRequest> >(JsonConvert.SerializeObject(respusta.ListaClientes).ToString()); return(Json(listaSalida)); } catch (Exception ex) { return(Json(false)); } }
public async Task <ActionResult> Create(Agente agente) { if (!ModelState.IsValid) { ViewBag.SectorId = new SelectList(await obtenerSectoresPorEmpresa(), "SectorId", "NombreSector", agente.SectorId); return(View(agente)); } IdentityPersonalizado ci = (IdentityPersonalizado)HttpContext.User.Identity; string nombreUsuario = ci.Identity.Name; var administrador = new Administrador { Nombre = nombreUsuario }; administrador = await ProveedorAutenticacion.GetUser(administrador); var codificar = CodificarHelper.SHA512(new Codificar { Entrada = agente.Nombre }); agente.Contrasena = codificar.Salida; agente.EmpresaId = administrador.EmpresaId; var response = await ApiServicio.InsertarAsync(agente, new Uri(WebApp.BaseAddress), "api/Agentes/CreateAgente"); if (!response.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index", "Agentes")); }
public async Task <ActionResult> Edit(int id) { if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var agente = new Agente { AgenteId = id }; var agenteRequest = await ApiServicio.ObtenerElementoAsync1 <Response>(agente, new Uri(WebApp.BaseAddress), "api/Agentes/GetAgente"); if (!agenteRequest.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var result = JsonConvert.DeserializeObject <Agente>(agenteRequest.Result.ToString()); ViewBag.SectorId = new SelectList(await obtenerSectoresPorEmpresa(), "SectorId", "NombreSector", result.SectorId); return(View(result)); }
public async Task <ActionResult> VerVendedoresTiempoReal(int?id, string mensaje) { InicializarMensaje(mensaje); if (id != null) { var vendedor = new VendedorRequest { IdVendedor = Convert.ToInt32(id) }; var vendedorRequest = await ApiServicio.ObtenerElementoAsync1 <Response>(vendedor, new Uri(WebApp.BaseAddress) , "api/Vendedores/ObtenerVendedor"); if (vendedorRequest.IsSuccess) { var vistaVendedor = JsonConvert.DeserializeObject <VendedorRequest>(vendedorRequest.Resultado.ToString()); var foto = string.IsNullOrEmpty(vistaVendedor.Foto) != true?vistaVendedor.Foto.Replace("~", WebApp.BaseAddress) : ""; vistaVendedor.Foto = foto; return(View(vistaVendedor)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public LoginVistaModelo() { this.apiServicio = new ApiServicio(); this.Recordar = true; this.habilitado = true; }
public async Task <JsonResult> ListaRutas(int IdVendedor, DateTime fecha) { var lista = new RutasVisitasRequest(); VendedorRequest vendedorRequest = new VendedorRequest(); vendedorRequest.FechaRuta = fecha; int idEmpresaInt = 0; try { ApplicationDbContext db = new ApplicationDbContext(); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); // obtener el idEmpresa var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; // convertir el idEmpresa a int idEmpresaInt = Convert.ToInt32(idEmpresa); //** agregar el idEmpresa al vendedorRequest ** vendedorRequest.idEmpresa = idEmpresaInt; //** agregar el idVendedor al vendedorRequest ** vendedorRequest.IdVendedor = IdVendedor; lista = await ApiServicio.ObtenerElementoAsync1 <RutasVisitasRequest>(vendedorRequest, new Uri(WebApp.BaseAddress), "api/Vendedores/ListarRutaVendedores"); return(Json(lista)); } catch (Exception ex) { return(Json(false)); } }
public async Task <ActionResult> PerfilCliente(int?id) { if (id == null) { RedirectToAction("Index"); } ; var cliente = new ClienteRequest { IdCliente = Convert.ToInt32(id), }; var respuesta = await ApiServicio.ObtenerElementoAsync1 <Response>(cliente, new Uri(WebApp.BaseAddress) , "api/Clientes/ObtenerCliente"); var clienteRequest = JsonConvert.DeserializeObject <ClienteRequest>(respuesta.Resultado.ToString()); var foto = string.IsNullOrEmpty(clienteRequest.Foto) != true?clienteRequest.Foto.Replace("~", WebApp.BaseAddress) : ""; clienteRequest.Foto = foto; var firma = string.IsNullOrEmpty(clienteRequest.Firma) != true?clienteRequest.Firma.Replace("~", WebApp.BaseAddress) : "";; clienteRequest.Firma = firma; var estadisticoVendedorRequest = await ApiServicio.ObtenerElementoAsync1 <EstadisticosClienteRequest>(clienteRequest, new Uri(WebApp.BaseAddress), "api/Clientes/VerEstadisticosCliente"); clienteRequest.EstadisticosClienteRequest = estadisticoVendedorRequest; return(View(clienteRequest)); }
public async Task <ActionResult> Asignarvendedor(string id, string idsupervisor) { try { var super = new SupervisorRequest { IdVendedor = Convert.ToInt32(id), IdSupervisor = Convert.ToInt32(idsupervisor) }; if (!string.IsNullOrEmpty(id)) { var response = await ApiServicio.ObtenerElementoAsync(super, new Uri(WebApp.BaseAddress), "api/Supervisor/Asignarvendedor"); if (response.IsSuccess) { InicializarMensaje(null); return(RedirectToAction("edit", new { id = idsupervisor })); } } } catch (Exception ex) { ex.ToString(); } return(View()); }
public async Task <JsonResult> ListaClientes() { var lista = new List <ClienteRequest>(); SupervisorRequest supervisorRequest = new SupervisorRequest(); VendedorRequest vendedorRequest = new VendedorRequest(); int idEmpresaInt = 0;; try { ApplicationDbContext db = new ApplicationDbContext(); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); // obtener el idEmpresa var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; // convertir el idEmpresa a int idEmpresaInt = Convert.ToInt32(idEmpresa); //** agregar el idEmpresa al vendedorRequest ** vendedorRequest.idEmpresa = idEmpresaInt; var idUsuarioActual = User.Identity.GetUserId(); supervisorRequest.IdUsuario = idUsuarioActual; supervisorRequest.IdEmpresa = idEmpresaInt; if (userManager.IsInRole(idUsuarioActual, "Supervisor")) { // obtener el Id del supervisor Response response = await ApiServicio.InsertarAsync(supervisorRequest, new Uri(WebApp.BaseAddress), "api/Vendedores/obtenerSupervisorPorIdUsuario"); supervisorRequest = JsonConvert.DeserializeObject <SupervisorRequest>(response.Resultado.ToString()); //** agregar el id del supervisor al vendedorRequest ** vendedorRequest.IdSupervisor = supervisorRequest.IdSupervisor; } lista = await ApiServicio.ObtenerElementoAsync1 <List <ClienteRequest> >(vendedorRequest, new Uri(WebApp.BaseAddress), "api/Vendedores/ListarClientesPorSupervisor"); return(Json(lista)); } catch (Exception ex) { return(Json(false)); } }
public async Task <ActionResult> EnviarCorreo(InfoRequest info) { var respuesta = await ApiServicio.InsertarAsync <Response>(info, new Uri(WebApp.BaseAddress) , "api/Informacion/Generar"); return (RedirectToAction("Index")); }
//Constructor public LugaresHistoricosVModelo() { instancia = this; this.apiServicio = new ApiServicio(); this.LoadLugaresHistoricos(); }
private async Task <List <AgenteRequest> > ObtenerAgentes() { var listaAgentes = await ApiServicio.Listar <AgenteRequest>( new Uri(WebApp.BaseAddress), "Simed/api/Agentes/GetAgentes"); return(listaAgentes); }
public EntidadesVModelo(Categoria categoria) { instancia = this; this.Categoria = categoria; this.apiEntidades = new ApiServicio(); LoadEntidades(); }
public NegociosVModelo(Categoria categoria) { instancia = this; this.IdCat = categoria.idCategoria; this.Categoria = categoria; this.apiServicios = new ApiServicio(); this.LoadLocales(); }
public DetalleSucursalVModelo(Sucursal sucursal) { this.Sucursal = sucursal; this.apiServicios = new ApiServicio(); this.CalleSucursal = sucursal.calle; this.NumeroSucursal = sucursal.numero; this.CalleIntersección = sucursal.calleIntersección; this.TelefonoSucursal = sucursal.telefono; }
public async Task <JsonResult> Cargar() { SupervisorRequest supervisorRequest = new SupervisorRequest(); try { var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; int idEmpresaInt = Convert.ToInt32(idEmpresa); ApplicationDbContext db = new ApplicationDbContext(); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); var idUsuarioActual = User.Identity.GetUserId(); var lista = new Response(); supervisorRequest.IdUsuario = idUsuarioActual; supervisorRequest.IdEmpresa = idEmpresaInt; if (userManager.IsInRole(idUsuarioActual, "Supervisor")) { lista = await ApiServicio.InsertarAsync(supervisorRequest, new Uri(WebApp.BaseAddress), "api/LogRutaVendedors/VendedoresPorSupervisor"); } else if (userManager.IsInRole(idUsuarioActual, "GerenteGeneral")) { Empresa empresa = new Empresa() { IdEmpresa = idEmpresaInt, }; lista = await ApiServicio.InsertarAsync(empresa, new Uri(WebApp.BaseAddress), "api/LogRutaVendedors/VendedoresPorEmpresa"); } if (lista.IsSuccess) { var listaVendedor = JsonConvert.DeserializeObject <List <VendedorPositionRequest> >(lista.Resultado.ToString()); List <VendedorPositionRequest> listaVendedores = new List <VendedorPositionRequest>(); foreach (var vendedor in listaVendedor) { vendedor.urlFoto = string.IsNullOrEmpty(vendedor.urlFoto) != true?vendedor.urlFoto.Replace("~", WebApp.BaseAddress) : ""; listaVendedores.Add(vendedor); } // var f = (DateTime)(listaVendedor.FirstOrDefault().fecha.Date); return(Json(listaVendedor)); } else { return(Json(false)); } } catch (Exception ex) { //InicializarMensaje(Mensaje.Excepcion); //lista.FirstOrDefault().NumeroMenu = 1; return(Json(false)); } }
public LoginViewModel() { dialogoSerices = new DialogoServices(); apiServicio = new ApiServicio(); this.IsEnabled = true; this.IsRunning = false; this.IsRemeber = true; this.Email = "*****@*****.**"; this.password = "******"; }
//constructor public SucursalVModelo(Local local) { instancia = this; this.Local = local; this.apiServicios = new ApiServicio(); this.ImageSource = local.fotoApp; this.NombreLocal = local.nombreLocal; this.DescripcionLocal = local.descripcion; this.PagWebLocal = local.pagWeb; this.LoadSucursales(); }
public async Task <ActionResult> PerfilVendedor(string mensaje, int idVendedor) { SupervisorRequest supervisorRequest = new SupervisorRequest(); VendedorRequest vendedor = new VendedorRequest(); vendedor.IdVendedor = idVendedor; int idEmpresaInt = 0; try { var userWithClaims = (ClaimsPrincipal)User; var idEmpresa = userWithClaims.Claims.First(c => c.Type == Constantes.Empresa).Value; idEmpresaInt = Convert.ToInt32(idEmpresa); vendedor.idEmpresa = idEmpresaInt; } catch (Exception ex) { InicializarMensaje(Mensaje.ErrorIdEmpresa); } InicializarMensaje("PerfilVendedor"); try { vendedor = await ApiServicio.ObtenerElementoAsync1 <VendedorRequest>(vendedor, new Uri(WebApp.BaseAddress), "api/Vendedores/ListarClientesPorVendedor"); var estadisticoVendedorRequest = await ApiServicio.ObtenerElementoAsync1 <EstadisticoVendedorRequest>(vendedor, new Uri(WebApp.BaseAddress), "api/Agendas/VerEstadisticosVendedor"); vendedor.estadisticoVendedorRequest = estadisticoVendedorRequest; var foto = string.IsNullOrEmpty(vendedor.Foto) != true?vendedor.Foto.Replace("~", WebApp.BaseAddress) : ""; vendedor.Foto = foto; InicializarMensaje(""); return(View(vendedor)); } catch { InicializarMensaje(Mensaje.Excepcion); return(View(vendedor)); } }
public JsonResult <bool> UpdateServicio(ApiServicio servicio) { bool result = false; if (ModelState.IsValid) { Servicio servicioUpdate = objMap.CreateMapper().Map <Servicio>(servicio); result = dataservServicio.UpdateServicio(servicioUpdate); } return(Json <bool>(result)); }
public JsonResult <bool> InsertServicio(ApiServicio servicio) { bool resultinsert = false; if (ModelState.IsValid) { Servicio servicioInsert = objMap.CreateMapper().Map <Servicio>(servicio); resultinsert = dataservServicio.InsertServicio(servicioInsert); } return(Json <bool>(resultinsert)); }